ASP.NET CORE 3.0 - HTTP Error 502.5 - Process Failure

社会主义新天地 提交于 2021-01-29 13:24:22

问题


After spending the past 3 days trying to resolve that problem, so I ask for your help. I already went to many related questions from stackoverflow, except that they are different .Net Core version.

I recently upgraded my website from ASP.NET CORE 2.2 to ASP.NET CORE 3.0 but now I keep receiving HTTP Error 502.5 - Process Failure on the website. You can see the page at http://www.esnapup.com.

Here is how the Startup.cs looks like:

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();
    }

The Program.cs page looks like below:

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>();
    });
}
}

Here's my .csproj codes:

   <?xml version="1.0" encoding="utf-8"?>
   <Project ToolsVersion="Current" 
     xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>

600 True False False MvcControllerEmptyScaffolder root/Controller 1440 False CustomProfile true

Please help me resolve the problem.

Thanks


回答1:


I asked the web hosting provider to install .Net Core SDK 3.0 and Runtime 3.0 to the server and added hostingModel="inProcess" to the web.config handlers so it looks like below.

<?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>



来源:https://stackoverflow.com/questions/58699234/asp-net-core-3-0-http-error-502-5-process-failure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!