-
Notifications
You must be signed in to change notification settings - Fork 0
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
61 changed files
with
24,438 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.28307.271 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExtensionMethods", "ExtensionMethods\ExtensionMethods.csproj", "{75B07550-507F-4D7A-993A-A4D795DF7EB3}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{75B07550-507F-4D7A-993A-A4D795DF7EB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{75B07550-507F-4D7A-993A-A4D795DF7EB3}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{75B07550-507F-4D7A-993A-A4D795DF7EB3}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{75B07550-507F-4D7A-993A-A4D795DF7EB3}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {598548FB-E846-4CD3-8249-D04A806B6EFE} | ||
EndGlobalSection | ||
EndGlobal |
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,49 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
using ExtensionMethods.Models; | ||
using ExtensionMethods.Extensions; | ||
|
||
namespace ExtensionMethods.Controllers | ||
{ | ||
public class HomeController : Controller | ||
{ | ||
public IActionResult Index() | ||
{ | ||
return View(); | ||
} | ||
|
||
public IActionResult About() | ||
{ | ||
ViewData["Message"] = "Your application description page."; | ||
|
||
return View(); | ||
} | ||
|
||
public IActionResult Contact() | ||
{ | ||
ViewData["Message"] = "Your contact page."; | ||
|
||
return View(); | ||
} | ||
|
||
public IActionResult Privacy() | ||
{ | ||
return View(); | ||
} | ||
public bool IsEmail(string str) | ||
{ | ||
if (string.IsNullOrWhiteSpace(str)) | ||
return false; | ||
return str.IsEmail(); | ||
} | ||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] | ||
public IActionResult Error() | ||
{ | ||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); | ||
} | ||
} | ||
} |
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,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.1</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.App" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" /> | ||
</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,48 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Text.RegularExpressions; | ||
using System.Threading.Tasks; | ||
|
||
namespace ExtensionMethods.Extensions | ||
{ | ||
public static class StringExtensions | ||
{ | ||
public static bool IsEmail(this string email) | ||
{ | ||
if (string.IsNullOrWhiteSpace(email)) | ||
return false; | ||
try | ||
{ | ||
email = Regex.Replace(email, @"(@)(.+)$", DomainMapper,RegexOptions.None, TimeSpan.FromMilliseconds(200)); | ||
string DomainMapper(Match match) | ||
{ | ||
var idn = new IdnMapping(); | ||
var domainName = idn.GetAscii(match.Groups[2].Value); | ||
return match.Groups[1].Value + domainName; | ||
} | ||
} | ||
catch (RegexMatchTimeoutException e) | ||
{ | ||
return false; | ||
} | ||
catch (ArgumentException e) | ||
{ | ||
return false; | ||
} | ||
try | ||
{ | ||
return Regex.IsMatch(email, | ||
@"^(?("")("".+?(?<!\\)""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" + | ||
@"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-0-9a-z]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$", | ||
RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250)); | ||
} | ||
catch (RegexMatchTimeoutException) | ||
{ | ||
return false; | ||
} | ||
} | ||
} | ||
} | ||
|
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,11 @@ | ||
using System; | ||
|
||
namespace ExtensionMethods.Models | ||
{ | ||
public class ErrorViewModel | ||
{ | ||
public string RequestId { get; set; } | ||
|
||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); | ||
} | ||
} |
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 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace ExtensionMethods | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
CreateWebHostBuilder(args).Build().Run(); | ||
} | ||
|
||
public static IWebHostBuilder CreateWebHostBuilder(string[] args) => | ||
WebHost.CreateDefaultBuilder(args) | ||
.UseStartup<Startup>(); | ||
} | ||
} |
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:52989", | ||
"sslPort": 44314 | ||
} | ||
}, | ||
"profiles": { | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"ExtensionMethods": { | ||
"commandName": "Project", | ||
"launchBrowser": true, | ||
"applicationUrl": "https://localhost:5001;http://localhost:5000", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
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,63 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.HttpsPolicy; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace ExtensionMethods | ||
{ | ||
public class Startup | ||
{ | ||
public Startup(IConfiguration configuration) | ||
{ | ||
Configuration = configuration; | ||
} | ||
|
||
public IConfiguration Configuration { get; } | ||
|
||
// This method gets called by the runtime. Use this method to add services to the container. | ||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
services.Configure<CookiePolicyOptions>(options => | ||
{ | ||
// This lambda determines whether user consent for non-essential cookies is needed for a given request. | ||
options.CheckConsentNeeded = context => true; | ||
options.MinimumSameSitePolicy = SameSiteMode.None; | ||
}); | ||
|
||
|
||
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); | ||
} | ||
|
||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. | ||
public void Configure(IApplicationBuilder app, IHostingEnvironment env) | ||
{ | ||
if (env.IsDevelopment()) | ||
{ | ||
app.UseDeveloperExceptionPage(); | ||
} | ||
else | ||
{ | ||
app.UseExceptionHandler("/Home/Error"); | ||
app.UseHsts(); | ||
} | ||
|
||
app.UseHttpsRedirection(); | ||
app.UseStaticFiles(); | ||
app.UseCookiePolicy(); | ||
|
||
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,7 @@ | ||
@{ | ||
ViewData["Title"] = "About"; | ||
} | ||
<h2>@ViewData["Title"]</h2> | ||
<h3>@ViewData["Message"]</h3> | ||
|
||
<p>Use this area to provide additional information.</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,17 @@ | ||
@{ | ||
ViewData["Title"] = "Contact"; | ||
} | ||
<h2>@ViewData["Title"]</h2> | ||
<h3>@ViewData["Message"]</h3> | ||
|
||
<address> | ||
One Microsoft Way<br /> | ||
Redmond, WA 98052-6399<br /> | ||
<abbr title="Phone">P:</abbr> | ||
425.555.0100 | ||
</address> | ||
|
||
<address> | ||
<strong>Support:</strong> <a href="mailto:[email protected]">Support@example.com</a><br /> | ||
<strong>Marketing:</strong> <a href="mailto:[email protected]">Marketing@example.com</a> | ||
</address> |
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,94 @@ | ||
@{ | ||
ViewData["Title"] = "Home Page"; | ||
} | ||
|
||
<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="6000"> | ||
<ol class="carousel-indicators"> | ||
<li data-target="#myCarousel" data-slide-to="0" class="active"></li> | ||
<li data-target="#myCarousel" data-slide-to="1"></li> | ||
<li data-target="#myCarousel" data-slide-to="2"></li> | ||
</ol> | ||
<div class="carousel-inner" role="listbox"> | ||
<div class="item active"> | ||
<img src="~/images/banner1.svg" alt="ASP.NET" class="img-responsive" /> | ||
<div class="carousel-caption" role="option"> | ||
<p> | ||
Learn how to build ASP.NET apps that can run anywhere. | ||
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkID=525028&clcid=0x409"> | ||
Learn More | ||
</a> | ||
</p> | ||
</div> | ||
</div> | ||
<div class="item"> | ||
<img src="~/images/banner2.svg" alt="Visual Studio" class="img-responsive" /> | ||
<div class="carousel-caption" role="option"> | ||
<p> | ||
There are powerful new features in Visual Studio for building modern web apps. | ||
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkID=525030&clcid=0x409"> | ||
Learn More | ||
</a> | ||
</p> | ||
</div> | ||
</div> | ||
<div class="item"> | ||
<img src="~/images/banner3.svg" alt="Microsoft Azure" class="img-responsive" /> | ||
<div class="carousel-caption" role="option"> | ||
<p> | ||
Learn how Microsoft's Azure cloud platform allows you to build, deploy, and scale web apps. | ||
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkID=525027&clcid=0x409"> | ||
Learn More | ||
</a> | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev"> | ||
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> | ||
<span class="sr-only">Previous</span> | ||
</a> | ||
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next"> | ||
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> | ||
<span class="sr-only">Next</span> | ||
</a> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col-md-3"> | ||
<h2>Application uses</h2> | ||
<ul> | ||
<li>Sample pages using ASP.NET Core MVC</li> | ||
<li>Theming using <a href="https://go.microsoft.com/fwlink/?LinkID=398939">Bootstrap</a></li> | ||
</ul> | ||
</div> | ||
<div class="col-md-3"> | ||
<h2>How to</h2> | ||
<ul> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkID=398600">Add a Controller and View</a></li> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699315">Manage User Secrets using Secret Manager.</a></li> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699316">Use logging to log a message.</a></li> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699317">Add packages using NuGet.</a></li> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699319">Target development, staging or production environment.</a></li> | ||
</ul> | ||
</div> | ||
<div class="col-md-3"> | ||
<h2>Overview</h2> | ||
<ul> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkId=518008">Conceptual overview of what is ASP.NET Core</a></li> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699320">Fundamentals of ASP.NET Core such as Startup and middleware.</a></li> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkId=398602">Working with Data</a></li> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkId=398603">Security</a></li> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkID=699321">Client side development</a></li> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkID=699322">Develop on different platforms</a></li> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkID=699323">Read more on the documentation site</a></li> | ||
</ul> | ||
</div> | ||
<div class="col-md-3"> | ||
<h2>Run & Deploy</h2> | ||
<ul> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkID=517851">Run your app</a></li> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkID=517853">Run tools such as EF migrations and more</a></li> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkID=398609">Publish to Microsoft Azure Web Apps</a></li> | ||
</ul> | ||
</div> | ||
</div> |
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,6 @@ | ||
@{ | ||
ViewData["Title"] = "Privacy Policy"; | ||
} | ||
<h2>@ViewData["Title"]</h2> | ||
|
||
<p>Use this page to detail your site's privacy policy.</p> |
Oops, something went wrong.