mirror of
https://github.com/markjprice/cs11dotnet7.git
synced 2026-04-21 06:03:57 +00:00
Initial commit
This commit is contained in:
parent
1da926d605
commit
638c6f8f2b
62 changed files with 372 additions and 90 deletions
|
|
@ -38,6 +38,12 @@ else
|
|||
// if you are using SQLite default is ..\Northwind.db
|
||||
builder.Services.AddNorthwindContext();
|
||||
|
||||
builder.Services.AddOutputCache(options =>
|
||||
{
|
||||
options.DefaultExpirationTimeSpan = TimeSpan.FromSeconds(20);
|
||||
options.AddPolicy("views", p => p.VaryByQuery(""));
|
||||
});
|
||||
|
||||
builder.Services.AddHttpClient(name: "Northwind.WebApi",
|
||||
configureClient: options =>
|
||||
{
|
||||
|
|
@ -77,16 +83,23 @@ else
|
|||
|
||||
app.UseHttpsRedirection();
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.UseOutputCache();
|
||||
|
||||
app.MapControllerRoute(
|
||||
name: "default",
|
||||
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||
pattern: "{controller=Home}/{action=Index}/{id?}")
|
||||
.CacheOutput("views");
|
||||
|
||||
app.MapRazorPages();
|
||||
|
||||
app.MapGet("/notcached", () => DateTime.Now.ToString());
|
||||
|
||||
app.MapGet("/cached", () => DateTime.Now.ToString()).CacheOutput();
|
||||
|
||||
// Section 4 - start the host web server listening for HTTP requests
|
||||
app.Run();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue