Skip to content
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.

Commit

Permalink
ADDED: .Net Core Version
Browse files Browse the repository at this point in the history
  • Loading branch information
stefmde committed Apr 15, 2017
1 parent 1d69625 commit 2831aa1
Show file tree
Hide file tree
Showing 36 changed files with 1,111 additions and 4 deletions.
26 changes: 24 additions & 2 deletions EasyGCaptchaMVC.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.26403.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyGCaptchaMVC", "EasyGCaptchaMVC\EasyGCaptchaMVC.csproj", "{82F9AA64-B9F3-4672-AF82-FB39C56686CB}"
EndProject
Expand All @@ -13,6 +13,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
README.md = README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".Net 4.5", ".Net 4.5", "{769EFAAE-EBE9-4477-9223-BA4EF8C99647}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".Net Core", ".Net Core", "{2359F7B1-061D-4A62-A195-A687EE67290F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyGCaptchaMVCCore", "EasyGCaptchaMVCCore\EasyGCaptchaMVCCore.csproj", "{5E8A79EE-EF91-4DE4-8975-00B36DC5DB71}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyGCaptchaMVCCore.Demo", "EasyGCaptchaMVCCore.Demo\EasyGCaptchaMVCCore.Demo.csproj", "{0DB7189E-8520-4B25-A8F6-BD334DEA8D02}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -27,8 +35,22 @@ Global
{E3ED254A-43E2-4BB8-8E7C-2F20C6E0AF4F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E3ED254A-43E2-4BB8-8E7C-2F20C6E0AF4F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E3ED254A-43E2-4BB8-8E7C-2F20C6E0AF4F}.Release|Any CPU.Build.0 = Release|Any CPU
{5E8A79EE-EF91-4DE4-8975-00B36DC5DB71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5E8A79EE-EF91-4DE4-8975-00B36DC5DB71}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5E8A79EE-EF91-4DE4-8975-00B36DC5DB71}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5E8A79EE-EF91-4DE4-8975-00B36DC5DB71}.Release|Any CPU.Build.0 = Release|Any CPU
{0DB7189E-8520-4B25-A8F6-BD334DEA8D02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0DB7189E-8520-4B25-A8F6-BD334DEA8D02}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0DB7189E-8520-4B25-A8F6-BD334DEA8D02}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0DB7189E-8520-4B25-A8F6-BD334DEA8D02}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{82F9AA64-B9F3-4672-AF82-FB39C56686CB} = {769EFAAE-EBE9-4477-9223-BA4EF8C99647}
{E3ED254A-43E2-4BB8-8E7C-2F20C6E0AF4F} = {769EFAAE-EBE9-4477-9223-BA4EF8C99647}
{5E8A79EE-EF91-4DE4-8975-00B36DC5DB71} = {2359F7B1-061D-4A62-A195-A687EE67290F}
{0DB7189E-8520-4B25-A8F6-BD334DEA8D02} = {2359F7B1-061D-4A62-A195-A687EE67290F}
EndGlobalSection
EndGlobal
3 changes: 3 additions & 0 deletions EasyGCaptchaMVCCore.Demo/.bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "wwwroot/lib"
}
36 changes: 36 additions & 0 deletions EasyGCaptchaMVCCore.Demo/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using EasyGCaptchaMVCCore.Configuration;
using EasyGCaptchaMVCCore.Demo.Models;
using EasyGCaptchaMVCCore.Model;
using EasyGCaptchaMVCCore.Worker;
using Microsoft.AspNetCore.Mvc;

namespace EasyGCaptchaMVCCore.Demo.Controllers
{
public class HomeController : Controller
{
[HttpGet]
public ActionResult Index()
{
GCaptchaSettingsProvider.Instance.Theme = Theme.Light;
GCaptchaSettingsProvider.Instance.Size = Size.Normal;

return View(new IndexViewModel());
}

[HttpPost]
[EasyGCaptcha]
public ActionResult Index(IndexViewModel model, EasyGCaptchaResult easyGCaptchaResult)
{
if (easyGCaptchaResult.Success)
{
// Do your work here
}
model.EasyGCaptchaResult = easyGCaptchaResult;
return View(model);
}
}
}
25 changes: 25 additions & 0 deletions EasyGCaptchaMVCCore.Demo/EasyGCaptchaMVCCore.Demo.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>

<PropertyGroup>
<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EasyGCaptchaMVCCore\EasyGCaptchaMVCCore.csproj" />
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions EasyGCaptchaMVCCore.Demo/Models/ContactViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace EasyGCaptchaMVCCore.Demo.Models
{
public class ContactViewModel
{
public string Name { get; set; }
public string Message { get; set; }
}
}
17 changes: 17 additions & 0 deletions EasyGCaptchaMVCCore.Demo/Models/IndexViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using EasyGCaptchaMVCCore.Model;

namespace EasyGCaptchaMVCCore.Demo.Models
{
public class IndexViewModel
{
public ContactViewModel ContactViewModel { get; set; }
public EasyGCaptchaResult EasyGCaptchaResult { get; set; }


public IndexViewModel()
{
ContactViewModel = new ContactViewModel();
EasyGCaptchaResult = new EasyGCaptchaResult();
}
}
}
25 changes: 25 additions & 0 deletions EasyGCaptchaMVCCore.Demo/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;

namespace EasyGCaptchaMVCCore.Demo
{
public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.UseApplicationInsights()
.Build();

host.Run();
}
}
}
27 changes: 27 additions & 0 deletions EasyGCaptchaMVCCore.Demo/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:23455/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"EasyGCaptchaMVCCore.Demo": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:23456"
}
}
}
60 changes: 60 additions & 0 deletions EasyGCaptchaMVCCore.Demo/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

namespace EasyGCaptchaMVCCore.Demo
{
public class Startup
{
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables();
Configuration = builder.Build();
}

public IConfigurationRoot Configuration { get; }

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();

if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Error");
}

app.UseStaticFiles();

app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
}
}
39 changes: 39 additions & 0 deletions EasyGCaptchaMVCCore.Demo/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@using EasyGCaptchaMVCCore
@using EasyGCaptchaMVCCore.Worker
@using Microsoft.AspNetCore.Mvc.ViewFeatures
@using Type = EasyGCaptchaMVCCore.Model.Type
@model EasyGCaptchaMVCCore.Demo.Models.IndexViewModel
<h1>EasyGCaptchaMVC Demo</h1>


@using (Html.BeginForm("Index", "Home", FormMethod.Post, new { @id = "contact-form", role = "form" }))
{
<h2>Protected form</h2>
@Html.LabelFor(x => x.ContactViewModel.Name, "Name") <br />
@Html.TextBoxFor(x => x.ContactViewModel.Name)

<br /><br />

@Html.LabelFor(x => x.ContactViewModel.Message, "Message") <br />
@Html.TextBoxFor(x => x.ContactViewModel.Message)

<br /><br />

@Html.EasyGCaptchaGenerateCaptcha()

<br /><br />

<button type="submit">Send</button>
}

<br />

@if (Model.EasyGCaptchaResult != null)
{
<h2>Result</h2>

@:State: @Model.EasyGCaptchaResult.Success <br />
@:Time: @Model.EasyGCaptchaResult.Date <br />
@:Hostname: @Model.EasyGCaptchaResult.Hostname <br />
@:Errors: @(Model.EasyGCaptchaResult.GErrorCodes == null ? "" : string.Join(", ", Model.EasyGCaptchaResult.GErrorCodes))
}
14 changes: 14 additions & 0 deletions EasyGCaptchaMVCCore.Demo/Views/Shared/Error.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@{
ViewData["Title"] = "Error";
}

<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>

<h3>Development Mode</h3>
<p>
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
</p>
<p>
<strong>Development environment should not be enabled in deployed applications</strong>, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>, and restarting the application.
</p>
24 changes: 24 additions & 0 deletions EasyGCaptchaMVCCore.Demo/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@inject Microsoft.ApplicationInsights.AspNetCore.JavaScriptSnippet JavaScriptSnippet
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - My ASP.NET Application</title>
<environment names="Development">
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" href="~/css/site.css" />
</environment>
<environment names="Staging,Production">
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css"
asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
<link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
</environment>
</head>
<body>
@RenderBody()

@RenderSection("scripts", required: false)
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<environment names="Development">
<script src="~/lib/jquery-validation/dist/jquery.validate.js"></script>
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"></script>
</environment>
<environment names="Staging,Production">
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.14.0/jquery.validate.min.js"
asp-fallback-src="~/lib/jquery-validation/dist/jquery.validate.min.js"
asp-fallback-test="window.jQuery && window.jQuery.validator"
crossorigin="anonymous"
integrity="sha384-Fnqn3nxp3506LP/7Y3j/25BlWeA3PXTyT1l78LjECcPaKCV12TsZP7yyMxOe/G/k">
</script>
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validation.unobtrusive/3.2.6/jquery.validate.unobtrusive.min.js"
asp-fallback-src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"
asp-fallback-test="window.jQuery && window.jQuery.validator && window.jQuery.validator.unobtrusive"
crossorigin="anonymous"
integrity="sha384-JrXK+k53HACyavUKOsL+NkmSesD2P+73eDMrbTtTk0h4RmOF8hF8apPlkp26JlyH">
</script>
</environment>
2 changes: 2 additions & 0 deletions EasyGCaptchaMVCCore.Demo/Views/_ViewImports.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@using EasyGCaptchaMVCCore.Demo
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
3 changes: 3 additions & 0 deletions EasyGCaptchaMVCCore.Demo/Views/_ViewStart.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@{
Layout = "_Layout";
}
10 changes: 10 additions & 0 deletions EasyGCaptchaMVCCore.Demo/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}
8 changes: 8 additions & 0 deletions EasyGCaptchaMVCCore.Demo/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Warning"
}
}
}
10 changes: 10 additions & 0 deletions EasyGCaptchaMVCCore.Demo/bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "asp.net",
"private": true,
"dependencies": {
"bootstrap": "3.3.7",
"jquery": "2.2.0",
"jquery-validation": "1.14.0",
"jquery-validation-unobtrusive": "3.2.6"
}
}
Loading

0 comments on commit 2831aa1

Please sign in to comment.