Minor bug fix (#13866)
parent
859d462e88
commit
e36c3f983f
|
@ -2,7 +2,6 @@ using Microsoft.AspNetCore.Hosting;
|
|||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using RazorPagesMovie.Data;
|
||||
using RazorPagesMovie.Models;
|
||||
using System;
|
||||
|
||||
|
@ -20,8 +19,6 @@ namespace RazorPagesMovie
|
|||
|
||||
try
|
||||
{
|
||||
var context = services.
|
||||
GetRequiredService<RazorPagesMovieContext>();
|
||||
SeedData.Initialize(services);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -39,9 +36,7 @@ namespace RazorPagesMovie
|
|||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
// webBuilder.UseStartup<Startup>();
|
||||
webBuilder.UseStartup<StartupVal>();
|
||||
|
||||
webBuilder.UseStartup<Startup>();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using RazorPagesMovie.Data;
|
||||
|
||||
namespace RazorPagesMovie
|
||||
{
|
||||
public class StartupVal
|
||||
{
|
||||
public StartupVal(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
#region snippet_ConfigureServices
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddRazorPages();
|
||||
|
||||
services.Configure<HtmlHelperOptions>(o => o.ClientValidationEnabled = false);
|
||||
|
||||
services.AddDbContext<RazorPagesMovieContext>(options =>
|
||||
options.UseSqlServer(Configuration.GetConnectionString("RazorPagesMovieContext")));
|
||||
}
|
||||
#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();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue