https://aka.ms/aspnetcore-makeover
- Intro (goals/non-goals/what you'll learn)
- Pick The Right Starting Template
- Web Application (no auth)
- Web API
- SPA
- Other templates (teaser)
- Source Control and Solution Structure
- editorconfig
- gitignore
- Maintainability
- Tests
- Health Checks
- Debug Footer
- Front End
- Bootstrap
- Front end build?
- Libman
- SEO
- Performance (no way we'll get to this in 50 minutes...)
- ANCM
- Tiered Compilation
- Language feature opt-in
- Caching
- Miniprofiler
- Creating your own templates
using Microsoft.AspNetCore.Mvc.Testing;
using OneHour.Web;
using System;
using System.Threading.Tasks;
using Xunit;
namespace WebApp.Tests
{
public class BasicTests
: IClassFixture<WebApplicationFactory<Startup>>
{
private readonly WebApplicationFactory<Startup> _factory;
public BasicTests(WebApplicationFactory<Startup> factory)
{
_factory = factory;
}
[Theory]
[InlineData("/")]
[InlineData("/Index")]
[InlineData("/Privacy")]
public async Task Get_EndpointsReturnSuccessAndCorrectContentType(string url)
{
// Arrange
var client = _factory.CreateClient();
// Act
var response = await client.GetAsync(url);
// Assert
response.EnsureSuccessStatusCode(); // Status Code 200-299
Assert.Equal("text/html; charset=utf-8",
response.Content.Headers.ContentType.ToString());
}
[Fact]
public async Task Get_HealthCheckReturnsHealthy()
{
// Arrange
var client = _factory.CreateClient();
// Act
var response = await client.GetAsync("/health");
// Assert
response.EnsureSuccessStatusCode(); // Status Code 200-299
Assert.Equal("Healthy",
response.Content.ReadAsStringAsync().Result);
}
}
}
{
"version": "1.0",
"defaultProvider": "cdnjs",
"libraries": [
{
"library": "[email protected]",
"files": [
"jquery.min.js",
"jquery.js",
"jquery.min.map"
],
"destination": "wwwroot/lib/jquery/dist"
},
{
"provider": "unpkg",
"library": "[email protected]",
"destination": "wwwroot/lib/bootstrap/",
"files": [
"dist/css/bootstrap.css",
"dist/css/bootstrap-grid.css",
"dist/css/bootstrap-reboot.css",
"dist/js/bootstrap.js"
]
},
{
"provider": "unpkg",
"library": "[email protected]",
"destination": "wwwroot/lib/ionicons",
"files": [ "dist/css/ionicons.min.css" ]
}
]
}
using Ducksoft.NetCore.Razor.Sitemap.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
namespace OneHour.Web.Utility
{
public static class SitemapExtensions
{
public static IServiceCollection ConfigureMvcRazorPages(this IServiceCollection services,
CompatibilityVersion version, string startPageUrl = "", string startPageArea = "")
{
services.AddMvc()
.SetCompatibilityVersion(version)
.AddRazorPagesOptions(options =>
{
var isSupportAreas = !string.IsNullOrWhiteSpace(startPageArea);
options.AllowAreas = isSupportAreas;
options.AllowMappingHeadRequestsToGetHandler = true;
if (isSupportAreas)
{
options.Conventions.AddAreaPageRoute(startPageArea, startPageUrl, string.Empty);
}
else if (!string.IsNullOrWhiteSpace(startPageUrl))
{
options.Conventions.AddPageRoute(startPageUrl, string.Empty);
}
})
.AddRazorPagesOptions(options =>
{
options.Conventions.Add(new SitemapRouteConvention());
})
.AddRazorPagesOptions(options =>
{
options.Conventions.AddPageRoute("/Sitemap", "sitemap.xml");
});
return services;
}
}
}
{
"$schema": "http://json.schemastore.org/template",
"author": "YOUR NAME",
"classifications": [ "ASP.NET Core", "Solution" ],
"identity": "[YOUR NAME].AspNetCoreSolutionTemplateTemplate.CSharp",
"name": "ASP.NET Core One Hour",
"shortName": "aspnetonehour",
"sourceName": "OneHour"
}
- An Opinionated Approach to ASP.NET Core - NDC - YouTube
- .NET Core Opinion #1 - Structuring a Repository
- .NET Core Opinion #2 - Managing a Repository Structure
- .NET Core Opinion #3 - Other Folders To Include in the Source Repository
- .NET Core Opinion #4 - Increase Productivity with Dev Scripts
- .NET Core Opinion #5 - Deployment Scripts and Templates
- .NET Core Opinion #6 - Be Wary of GUI Build Tools
- Community blogger's transcription
-
Dev Adventures .NET Core project setup. - Visual Studio Marketplace
-
Web Applications with ASP.NET Core Architecture and Patterns guidance (Updated for .NET Core 2.0)
-
ASP.NET Core - Best practices (tips and tricks) - an opinionated approach - Part 1
-
gothinkster/aspnetcore-realworld-example-app: ASP.NET Core backend implementation for RealWorld
-
VahidN/EFSecondLevelCache.Core: Entity Framework Core Second Level Caching Library
-
SteffenMangold/EntityFrameworkCore.Cacheable: EntityFrameworkCore second level cache
-
ASP.NET Core Best Practices - Opinionated Approach - CodingBlast
-
url redirection - Redirect asp.net core 2.0 urls to lowercase - Stack Overflow
-
AddOptions (strongly typed)
-
https://github.com/AArnott/Nerdbank.GitVersioning/blob/master/doc/dotnet.md
-
https://dotnetthoughts.net/how-to-display-app-version-in-aspnet-core/
-
https://github.com/JosephWoodward/GlobalExceptionHandlerDotNet
-
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-2.2