Permalink
Rick-Anderson
3.0 update: intro to RP (#13993)
252bfa8
Sep 19, 2019
Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up
Find file
Copy path
AspNetCore.Docs/aspnetcore/razor-pages/index/3.0sample/RazorPagesContacts/Startup.cs
Find file
Copy path
using Microsoft.AspNetCore.Builder; | |
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.EntityFrameworkCore; | |
using Microsoft.Extensions.Configuration; | |
using Microsoft.Extensions.DependencyInjection; | |
using Microsoft.Extensions.Hosting; | |
using RazorPagesContacts.Data; | |
namespace RazorPagesContacts | |
{ | |
public class Startup | |
{ | |
public Startup(IConfiguration configuration) | |
{ | |
Configuration = configuration; | |
} | |
public IConfiguration Configuration { get; } | |
#region snippet | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddDbContext<CustomerDbContext>(options => | |
options.UseInMemoryDatabase("name")); | |
services.AddRazorPages(); | |
} | |
#endregion | |
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) | |
{ | |
if (env.IsDevelopment()) | |
{ | |
app.UseDeveloperExceptionPage(); | |
} | |
else | |
{ | |
app.UseExceptionHandler("/Error"); | |
app.UseHsts(); | |
} | |
app.UseHttpsRedirection(); | |
app.UseStaticFiles(); | |
app.UseRouting(); | |
app.UseAuthorization(); | |
app.UseEndpoints(endpoints => | |
{ | |
endpoints.MapRazorPages(); | |
}); | |
} | |
} | |
} |