AspNetCore.Docs/aspnetcore/includes/RP/code/StartupDevProd.cs

69 lines
1.8 KiB
C#
Raw Normal View History

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using RPauth.Data;
namespace RPauth
{
#region snippet
public class Startup
{
public Startup(IConfiguration configuration, IWebHostEnvironment env)
{
Environment = env;
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public IWebHostEnvironment Environment { get; }
public void ConfigureServices(IServiceCollection services)
{
if (Environment.IsDevelopment())
{
services.AddDbContext<RazorPagesMovieContext>(options =>
options.UseSqlite(
5.0 update - Rewrite: Razor Pages Get Started Tutorial Series (#20348) * Moving all from PR #19859 to new PR due to unfixable merge conflicts that could not be reverted * patch: model.md: added last of ScottAddie's recommendations. * patch: corrected Solution Explorer and right click for mac in original content, all versions * Apply suggestions from Scott Addie review Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> * patch: minor fix per recommendation * Apply ScottAddie's suggestions. Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> * Encorporated all of Rick-Anderson and ScottAddie's great review suggestions. * patch: added a minor punctuation. * patch: forcing updates for .png screenshots that were not picked up earlier as changed * patch: Udating da1.md to use forced m55htpps.png update * patch: removed en-us from three new links in sql.md * patch: forcing more png updates that did not commit in 1st draft. * Update aspnetcore/tutorials/razor-pages/razor-pages-start.md Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> * Incorporating additional suggestions from ScottAddie Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> * Review suggestions from ScottAddie; Fixing DataAnnotations link Removing a DataAnnotations link dupe that was both both above and below the IDE tabs and changing < to ( Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> * patch: forced update of val.png used in validation.md * Added suggestions from Rick-Anderson for those where the changes were entered directly. Co-authored-by: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com> * Incorporated review feedback form Rick-Anderson: Moved Movie Class instruction below tabs, added additional VS code tab to accommidate * patch: removed copy paste dupe of move class instrucion * patch: backed out of acrobatics to try to avoid repeating the movie class insturction in 3 IDE tabs * patch: Review suggestions by Rick-Anderson - page.md remove cookbook step - fix code include * patch: updated start instruction for new project with link and added screenshot. * patch: razor-pages-start.md: fixed create project image alignment and reduced image size. * patch: razor-pages-start.md: Changed download link * Incorporated ScottAddie's additional suggestions. Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> * patch: np.png: added red border on next button. * patch: forced update of np.png * patch: config.png added highlight, razor-pages-start, added rick anderson suggestions * forced config.png update that was not picking up. Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> Co-authored-by: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com>
2020-11-07 06:26:26 +08:00
Configuration.GetConnectionString("RazorPagesMovieContext")));
}
else
{
services.AddDbContext<RazorPagesMovieContext>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("MovieContext")));
}
services.AddRazorPages();
}
public void Configure(IApplicationBuilder app)
{
if (Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
}
else
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
});
}
}
#endregion
}