HTTP错误500.30-ANCM进程内启动失败.NET Core

时间:2019-12-18 12:43:02

标签: c# iis-express appsettings asp.net-core-3.0

我正在使用.NET Core 3.0,突然在下面出现错误,是的,上周工作正常:-

尽管如此,但情况有所改变,我无法进行锻炼-似乎与目录错误有关。 我已删除了.vs,希望它在重新生成后能正常工作...

Error

我关注了以下链接,但无济于事...

HTTP Error 500.30 - ANCM In-Process Start Failure

Reading and using appsettings.json in Program.cs?

https://forums.asp.net/t/2159371.aspx?Application+LM+W3SVC+10+ROOT+failed+to+start+process+ErrorCode+0x80070005+

Dotnet Core Multiple Startup Classes with In-Process Hosting

事件查看器显示:-

enter image description here

添加StartUp.cs

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.AddMvc();

        services.AddAuthorization(options =>
        {
            options.AddPolicy("ADGroup", policy =>
                policy.Requirements.Add(new UserHelper.CheckAdGroupRequirement(Configuration["SecuritySettings:ADGroup"])));
        });

        services.AddSingleton<IAuthorizationHandler, UserHelper.CheckAdGroupHandler>();
        services.AddHttpContextAccessor();
    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public static void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();

        }
        else
        {
            app.UseExceptionHandler("/Home/Error/{0}");
            // 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.UseRouting();

        app.UseAuthentication();
        app.UseAuthorization();

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapRazorPages();
            endpoints.MapControllerRoute(
                name: "default",
                pattern: "{controller=Home}/{action=Index}/{id?}");
        });


    }
}

高度赞赏朝着正确方向前进。...

0 个答案:

没有答案