asp.net-core - asp .net core 5 beta - 找不到默认文件
问题描述
我正在尝试将旧的 Web 应用程序升级到带有剃须刀页面的 asp .net 核心。我决定使用 .net core v5 beta。我正在尝试验证我的设置。当找不到我在 pages 目录中设置的 index.cshtml 文件时,我收到 404 错误。关于如何解决这个问题的任何想法?我有以下设置,并假设我做错了什么。任何想法表示赞赏。TIA
Startup.cs 文件: public class Startup { public static IConfigurationRoot Configuration { get; 放; }
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
var builder = new ConfigurationBuilder()
.SetBasePath(System.IO.Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json");
Configuration = builder.Build();
services.AddDbContext<GolfGameContext>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection"),
x =>
{
x.UseNetTopologySuite();
x.EnableRetryOnFailure();
}
));
services.AddElmah<SqlErrorLog>(options =>
{
options.ConnectionString = Configuration.GetConnectionString("DefaultConnection");
});
services.AddDefaultIdentity<AspNetUser>(options => options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<GolfGameContext>();
services.AddScoped<UserManager<AspNetUser>>();
services.AddScoped<SignInManager<AspNetUser>>();
services.Configure<IdentityOptions>(options =>
{
// Password settings
options.Password.RequireDigit = true;
options.Password.RequiredLength = 8;
options.Password.RequireNonAlphanumeric = false;
options.Password.RequireUppercase = true;
options.Password.RequireLowercase = false;
options.Password.RequiredUniqueChars = 6;
// Lockout settings
options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(30);
options.Lockout.MaxFailedAccessAttempts = 10;
options.Lockout.AllowedForNewUsers = true;
// User settings
options.User.RequireUniqueEmail = false;
});
services.ConfigureApplicationCookie(options =>
{
// Cookie settings
options.Cookie.HttpOnly = true;
options.ExpireTimeSpan = TimeSpan.FromDays(150);
options.LoginPath = "/Account/Login"; // If the LoginPath is not set here, ASP.NET Core will default to /Account/Login
options.LogoutPath = "/Account/Logout"; // If the LogoutPath is not set here, ASP.NET Core will default to /Account/Logout
options.AccessDeniedPath = "/Account/AccessDenied"; // If the AccessDeniedPath is not set here, ASP.NET Core will default to /Account/AccessDenied
options.SlidingExpiration = true;
});
services.AddMvc().AddRazorPagesOptions(options =>
{
});
services.AddAuthorization(options =>
{
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseStaticFiles();
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
endpoints.MapControllers();
});
app.UseElmah();
}
}
解决方案
推荐阅读
- java - 如何在 laravel 中返回 Content 类型?
- kotlin - 带有 Java 超类的 Kotlin 数据类
- c++ - GCC avx2intrin.h(版本 X-9.2)中缺少 _mm_broadcastsd_pd
- excel - excel SQL VBA更新2个访问表
- google-chrome - 从 Firebase 提供时,带有范围请求路由器的 Workbox 预缓存音频无法在 Chrome 中播放
- pyspark - 如何在 PySpark 中的两个日期之间生成每小时时间戳?
- javascript - Ajax POST 仅在页面刷新时执行 php 脚本
- c - 在 C 中打印 3d 数组中的 2d 部分(分段错误)
- plot - GNUplot - 使用窗口坐标系画线
- vb.net - 使用 VB.Net 在 MS Project 中生成资源使用时间阶段性数据