突然,Web应用程序不再显示开发人员异常页面

时间:2018-03-21 06:48:03

标签: c# asp.net-core error-handling development-environment

我正在使用Visual Studio 2017社区版在ASP.NET Core中开发MVC webapp。到目前为止一切都很顺利,但是,自从过去几天以来,UseDeveloperExceptionPage不再处理应用程序中的错误。环境是“发展”。我试图评论出来'在' Startup.cs'中的指令看是否默认" / Home / Error"页面会显示,但这也不起作用,因此似乎没有处理错误...期间!

基本上发生的事情是浏览器永远不会离开我发送最后一个请求的页面(但它也不会冻结/崩溃),如果我想知道发生了什么,我需要查看输出VS2017中ASP.Net核心Web服务器的窗口。

无论我是在调试模式还是在无调试模式下运行,行为都是相同的。 显然,我并没有故意做任何事情来实现这个目标...任何想法会导致这个或者我应该看到什么?

这是Startup.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using WebApp.Data;
using WebApp.Models;
using WebApp.Services;

namespace WebApp {
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.AddDbContext<ApplicationDbContext>(options =>
            options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

        services.AddIdentity<ApplicationUser, IdentityRole>()
            .AddEntityFrameworkStores<ApplicationDbContext>()
            .AddDefaultTokenProviders();

        // Add application services.
        services.AddTransient<IEmailSender, EmailSender>();

        services.AddMvc();

        services.AddScoped<IGenericRepository<Account>, GenericRepository<Account>>();
        services.AddScoped<IGenericRepository<Period>, GenericRepository<Period>>();
        services.AddScoped<Report>();
    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseBrowserLink();
            app.UseDeveloperExceptionPage();
            app.UseDatabaseErrorPage();
        }
        else
        {
            app.UseExceptionHandler("/Home/Error");
        }

        app.UseStaticFiles();

        app.UseAuthentication();

        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");
        });
    }
} }

这是launchSettings.json:

&#13;
&#13;
{
	"iisSettings": {
		"windowsAuthentication": false,
		"anonymousAuthentication": true,
		"iisExpress": {
			"applicationUrl": "http://localhost:64904/",
			"sslPort": 44374
		}
	},
	"profiles": {
		"IIS Express": {
			"commandName": "IISExpress",
			"launchBrowser": true,
			"launchUrl": "https://localhost:44374/",
			"environmentVariables": {
				"ASPNETCORE_ENVIRONMENT": "Development"
			}
		},
		"WebApp": {
			"commandName": "Project",
			"launchBrowser": true,
			"environmentVariables": {
				"ASPNETCORE_ENVIRONMENT": "Development"
			},
			"applicationUrl": "http://localhost:64905/"
		}
	}
}
&#13;
&#13;
&#13;

0 个答案:

没有答案