在过去3天里尝试解决该问题后,因此,我寻求您的帮助。我已经从stackoverflow讨论了许多相关的问题,除了它们是不同的.Net Core版本。
我最近将网站从ASP.NET CORE 2.2升级到ASP.NET CORE 3.0,但是现在我在该网站上继续收到HTTP Error 502.5 - Process Failure
。您可以在http://www.esnapup.com上看到该页面。
这是Startup.cs的样子:
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.AddAuthentication(IISServerDefaults.AuthenticationScheme);
services.AddDbContext<AppDbContext>();
services.AddTransient<IProductRepository, ProductRepository>();
services.AddTransient<ICategoryRepository, CategoryRepository>();
services.AddTransient<IFeedRepository, FeedRepository>();
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddDistributedMemoryCache();
services.AddSession(options =>
{
// Set a short timeout for easy testing.
options.IdleTimeout = TimeSpan.FromSeconds(10);
options.Cookie.HttpOnly = true;
// Make the session cookie essential
options.Cookie.IsEssential = true;
});
MvcOptions mvcOptions = new MvcOptions();
mvcOptions.EnableEndpointRouting = false;
services.AddMvc();
services.AddRazorPages();
}
// 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.EnvironmentName == "Development")
{
app.UseDeveloperExceptionPage();
app.UseStatusCodePages();
}
else
{
app.UseExceptionHandler("/Home/Error");
//app.UseExceptionHandler("/Raffaello/Index");
// 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.UseHttpsRedirection();
app.UseStaticFiles();
app.UseSession();
//app.UseCookiePolicy();
app.UseRouting();
app.UseAuthentication();
app.UseEndpoints(routes =>
{
routes.MapControllerRoute(
name: "Details",
pattern: "{controller}/{Details}/{id?}",
new { controller = "Product", action = "Details" },
new { id = @"w+" });
routes.MapControllerRoute(
name: "Detail",
pattern: "{controller}/{index}/{Detail}/{id?}",
new { controller = "Product", action = "Detail", level = "index" },
new { id = @"w+" });
routes.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
routes.MapRazorPages();
});
//app.UseSitemapMiddleware();
}
Program.cs页面如下:
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
namespace SnapupMVC
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseSetting(
WebHostDefaults.PreventHostingStartupKey, "true")
.UseStartup<Startup>();
});
}
}
这是我的.csproj代码:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
600 真正 假 假 MvcControllerEmptyScaffolder 根/控制器 1440 假 CustomProfile 真正
请帮助我解决问题。
谢谢
答案 0 :(得分:0)
我要求虚拟主机提供商将.Net Core SDK 3.0和Runtime 3.0安装到服务器上,并将hostingModel="inProcess"
添加到web.config处理程序中,如下所示。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" hostingModel="inProcess">
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Production" />
</environmentVariables>
</aspNetCore>
</system.webServer>