【发布时间】:2017-03-30 23:34:42
【问题描述】:
我正在使用 Visual Studio 2015 Update 3 和 ASP.NET Core。其中一个 API(帐户)依赖于使用 Redis 的缓存服务。
public AccountController(Cache.Contracts.ICacheManager cacheManager)
{
_cacheManager = cacheManager;
}
当 Redis 没有运行时,api/account 不应该工作,因为缓存服务应该连接到 Redis。
在启动类中:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole();
loggerFactory.AddDebug();
}
请求api/账号时
从 Visual Studio 运行项目
它给出了以下内容:
The localhost page isn’t working
localhost is currently unable to handle this request.
从 powershell 运行时使用dotnet run:
这也是异常设置
问题
为什么在 Visual Studio 案例中不抛出错误?我需要知道是什么错误导致我的应用程序崩溃。
【问题讨论】:
-
一个问题是,如果您只是在 VS 中使用“启动而不调试”运行您的应用程序,您会收到任何编译错误吗?对于未处理的异常,我们经常在Debug->Windows->Exception设置下开启,但如果在调试的时候代码没有真正调用或者出现编译错误,则不会抛出异常信息。
-
没有复杂错误,我也检查了异常窗口中的所有公共语言运行时异常
-
如果您查看输出窗口,并选择“调试”下拉列表,您会得到异常吗?我知道在启用/禁用 JIT 调试或其他后,它可以在输出窗口中显示异常,而不会在调试期间在 TOOLS->Options->Debugging->Output window->Exception 消息下抛出异常。
标签: asp.net-mvc exception dependency-injection asp.net-core visual-studio-debugging