简体   繁体   English

MVC5应用程序无法正确调试

[英]MVC5 Application not Debugging Correctly

I have a very weird problem. 我有一个很奇怪的问题。

I've been creating my application and building it and running it. 我一直在创建我的应用程序并构建它并运行它。 Chrome pops up with its tab and the page loads. Chrome弹出并显示其标签,然后加载页面。

The last things I can remember installing before the app went haywire is Unity. 我记得在应用程序正式发布之前安装的最后一件事是Unity。

So now, I build, I click run in Chrome and the VS doesn't show any pages. 所以现在,我进行构建,单击Chrome中的run,VS不会显示任何页面。 The IIS express is running to point where I can query for pages like Home/Index but when I query my JsonResult Blog/Blogs I get a 500 error. IIS Express正在运行,指向可以查询诸如Home/Index类的页面,但是当我查询JsonResult Blog/Blogs出现500错误。 I've used fiddler and I can hit the standard URLs but not my JsonResult. 我用过提琴手,可以打标准URL,但不能打我的JsonResult。

Usually if you're on a page editing it, then you hit F5, chrome will load up that page in the browser. 通常,如果您正在页面上对其进行编辑,然后按F5键,Chrome将在浏览器中加载该页面。 VS isn't doing that anymore. VS不再这样做了。

The only thing I can pin it down to is Unity..... 我唯一可以确定的就是Unity .....

If in the Fiddler response you cannot pinpoint the exact reason why your server returned 500 error you may try debugging your code. 如果在Fiddler响应中您无法查明服务器返回500错误的确切原因,则可以尝试调试代码。 So start by enabling all errors. 因此,首先启用所有错误。 In VS use Ctrl+D+E and then make sure that Common Language Runtime Exceptions is selected: 在VS中,使用Ctrl + D + E ,然后确保选择了“ Common Language Runtime Exceptions

在此处输入图片说明

Now F5 into your application, click Continue on all potential exceptions you don't recognize, and then in the browser navigate to the controller action that unleashed the 500 error. 现在将F5插入您的应用程序,在您不认识的所有潜在异常上单击“ Continue ”,然后在浏览器中导航到释放500错误的控制器操作。 Chances are that the debugger will pinpoint you to the precise reason of this unhandled error. 调试器可能会为您指出此未处理错误的确切原因。

NOTE: Don't forget to turn off the breaking on all Common Language Runtime exceptions settings once you have identified the problem or you might get flooded with lots of verbose errors. 注意:确定问题后,不要忘记关闭所有“ Common Language Runtime异常设置,否则您可能会遇到很多详细错误。

NOTE2: Usually you don't need to resort to this heavy debugging artillery, just by inspecting the error response in Fiddler/Web developer toolbar of your webbrowser, you could come to the conclusion. 注意2:通常,您无需借助繁重的调试工具,只需检查Web浏览器的Fiddler / Web开发人员工具栏中的错误响应即可得出结论。

It was due to the last thing I added: Unity. 这是由于我最后添加的内容:Unity。

Just as an FYI, the reason no errors were coming back is because none of the controllers serving up my pages had an interface injected into them. 就像FYI一样,没有错误返回的原因是,为我的页面提供服务的所有控制器都没有注入接口。

The only controller that had an interface injected into it was the toolbox controller and that was getting accessed via this JSON call. 唯一注入接口的控制器是工具箱控制器,并且可以通过此JSON调用进行访问。 The response that was coming back was a HTML page but you could only view that in the Chrome network tab of the console. 返回的响应是一个HTML页面,但是您只能在控制台的Chrome网络选项卡中查看它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM