我完全困在IIS 10上的一个简单的..net core 3.1应用程序上,它顽固地给出了"500内部错误“,但拒绝给出任何关于这个问题的日志或任何其他提示。
这个应用程序在dev env中运行得很好,一开始使用"dotnet myapp.dll“。
H 113日志目录(我把它们放在任何地方,(以防万一)被创建并显示“每个人”都有写访问权限,web.config是:
<aspNetCore processPath=".\MyApp.exe" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />我可以启动它并使用"dotnet myapp.dll“运行它这一事实告诉我,应用程序本身似乎没有什么问题。
有什么办法可以得到一些日志,或更好的"500内部错误页“吗?Windows事件日志或W3C日志中没有任何内容,在任何.\logs目录中也没有。只是该死的"500内部错误“,没有给出真正的问题的线索。
我将永远感谢你提出一些明智的建议。
//马丁
增编,启动类,在测试过程中不断地和断断续续地进行一些评论:
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews();
services.AddTransient<AppDb>(_ => new AppDb(Configuration["ConnectionStrings:validAndWorkingString"]));
services.AddDistributedMemoryCache();
services.AddSession(options =>
{
options.IdleTimeout = TimeSpan.FromSeconds(10);
options.Cookie.HttpOnly = true;
options.Cookie.IsEssential = true;
});
}
// 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("/Home/Error");
// // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
// app.UseHsts();
//}
app.UseSession();
// app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
}
}并且FWIW程序类,其中我已经测试了bot useKestrel,而不是使用相同的行为:
public class Program
{
public static void Main(string[] args)
{
bool useKestrel = true;
if (useKestrel)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
}
else
{
CreateHostBuilder(args).Build().Run();
}
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}发布于 2020-10-26 11:11:46
谢谢您的帮助和建议!
与以往一样,解决方案比预期的要简单。
我使用“删除所有文件”设置时发布,以确保有一个干净的安装。我没有意识到这个发布删除了整个应用程序目录,然后再重新创建它。由于未知的原因,应用程序的父目录失去了IIS_IUSRS权限,因此自动(!)创建的应用程序目录从未继承必要的权限。我一开始就仔细设置了权限。
谢谢!
发布于 2022-11-07 20:34:20
确保将IIS_IUSR权限授予根文件夹。
https://stackoverflow.com/questions/64529830
复制相似问题