c# - ASP.NET 核心在发布到文件夹并将其添加到 IIS 时默认主页/索引返回空白页
问题描述
当我将网页发布到文件夹并将其添加到 IIS 时,一切正常,除了登录时它重定向我的默认页面。什么都没有加载它只是这个
<html>
<head>
<link rel="alternate stylesheet" type="text/css" href="resource://content-accessible/plaintext.css" title="Prelomi dolge vrstice">
</head>
<body>
<pre></pre>
</body>
</html>
布局没有加载,什么都没有。
这是我的 Startup.cs
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
if (env.IsDevelopment())
{
// For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
builder.AddUserSecrets<Startup>();
// This will push telemetry data through Application Insights pipeline faster, allowing you to view results immediately.
builder.AddApplicationInsightsSettings(developerMode: true);
}
builder.AddEnvironmentVariables();
Configuration = builder.Build();
}
public IConfigurationRoot Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddApplicationInsightsTelemetry(Configuration);
//var connection = @"Server=localhost\SQLEXPRESS;Database=endoIS;Integrated Security=False;MultipleActiveResultSets=true;Persist Security Info=False;User ID=admin;Password=000000";
//services.AddDbContext<EndoContext>(options => options.UseSqlServer(connection));
// services.AddIdentity<ApplicationUser, IdentityRole>()
// .AddEntityFrameworkStores<EndoContext>()
// .AddDefaultTokenProviders();
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
services.AddMvc();
services.AddScoped<SignInManager<ApplicationUser>, SignInManager<ApplicationUser>>();
services.Configure<PasswordHasherOptions>(options =>
options.CompatibilityMode = PasswordHasherCompatibilityMode.IdentityV2
);
// Add application services.
services.AddTransient<IEmailSender, AuthMessageSender>();
services.AddTransient<ISmsSender, AuthMessageSender>();
services
.AddMvc()
.AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver());
// Add Kendo UI services to the services container
services.AddKendo();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
app.UseApplicationInsightsRequestTelemetry();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
app.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Index");
}
app.UseApplicationInsightsExceptionTelemetry();
app.UseStaticFiles();
app.UseIdentity();
// Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Evidenca}/{action=Index}/");
});
// Configure Kendo UI
app.UseKendo(env);
}
即使我尝试通过调用控制器和方法来进入默认页面,它也是一样的
解决方案
推荐阅读
- python - 如何重复调用一个函数?
- node.js - “编译后无法覆盖模型” Next.js 和 Mongoose Schemas
- mapbox - 聆听点击 MapBox 地理编码器的“X”按钮
- powershell - Powershell - 如果 OU 有要计算的用户,则仅显示用户数
- ios - iOS 14.2 中的 SwiftUI PageTabView 性能问题滞后
- python - matplotlib:如何在标记标签中添加逗号?
- python - 在 WTForms (Flask) 中使用单个类创建多个输入元素
- android - 在 MotionScene 期间在 textView 上添加可绘制对象
- python - 比较和切换字典中的键值
- extjs - 将变量传递给按钮的处理程序