Visual Studio 2013 - Debugging MVC code with ViewBag properties deathly slow and unusable

浪尽此生 提交于 2019-12-11 07:26:09

问题


I'm trying out the latest Visual Studio, but debugging the most elementary MVC application with ViewBag dynamic variables gives me a lot of headache.

I'm running Visual Studio 2013 under 32-bit Windows 8 operating system with clean install and every available update applied.

I created new ASP.NET Web Application (.NET Framework 4.5 - New Solution) with folders and core references for MVC after which I added sample Home controller with some element code:

dynamic d1 = 1;
dynamic d2 = 2;

ViewData["Vd1"] = 1;
ViewData["Vd2"] = 2;

ViewBag.Vb1 = 1;
ViewBag.Vb2 = 2;

Hitting breakpoint at the first line and stepping to the second until the ViewBag property worked fine (instantly) - then, in the Output window I got:

A first chance exception of type 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' occurred in Microsoft.CSharp.dll

...and stepping to the second line (ViewBag.Vb2...) took couple of seconds. I tested different dynamic variables to make sure the problems are with ViewBag properties.

What causes the exception and so slow debugging under IIS Express? Extensive use of ViewBag properties makes debugging a nightmare!

Calling again the script under Debug don't cause the exceptions, and debug works fine because the Debugging Symbols are all loaded (guessing).

I tried lots of different suggestions available at Stack Overflow and else over the net, but non of it works!


回答1:


One of the overlooked and never reported issues on increasing debug speed for visual studio 2013 ASP .NET apps (MVC and webforms) is to disable browser link. This is a new feature in VS 2013 which causes a huge amount of overhead and causes pages to load extremely slowly (5-10 seconds in most of my cases). Disabling it brings it back to Visual Studio 2012 speeds.

See here for how to disable it:

http://blogs.msdn.com/b/webdev/archive/2013/06/28/browser-link-feature-in-visual-studio-preview-2013.aspx




回答2:


What worked for me was to choose another browser other than Internet Explorer. IF I used Chrome or Firefox, debugging is lightning fast. Turning off browser link did not help for Internet Explorer for me.

Here is a link on how to change to another browser when debugging.

http://www.asp.net/visual-studio/overview/2013/using-browser-link#browser-refresh



来源:https://stackoverflow.com/questions/19611765/visual-studio-2013-debugging-mvc-code-with-viewbag-properties-deathly-slow-and

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