This repository has been archived by the owner on Feb 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
1,111 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"directory": "wwwroot/lib" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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?}"); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
18 changes: 18 additions & 0 deletions
18
EasyGCaptchaMVCCore.Demo/Views/Shared/_ValidationScriptsPartial.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@using EasyGCaptchaMVCCore.Demo | ||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@{ | ||
Layout = "_Layout"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"Logging": { | ||
"IncludeScopes": false, | ||
"LogLevel": { | ||
"Default": "Debug", | ||
"System": "Information", | ||
"Microsoft": "Information" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"Logging": { | ||
"IncludeScopes": false, | ||
"LogLevel": { | ||
"Default": "Warning" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
Oops, something went wrong.