How to debug into ASP.NET MVC source code? I guess debug into framework source code is very easily done in PHP or Java Frameworks, right? Usually it goes directly into framework source code. How about ASP.NET MVC?
btw, .NET is fully open-source? So debugging should now be the same as in PHP and Java?
答案 0 :(得分:2)
Almost all work done on asp.net mvc is done in visual studio so I will assume that is what you are using. There are several issues to keep in mind when debugging the mvc project in visual studio.
c# (server side)
This is pretty straight forward. Ensure that your project is running
And set a breakpoint
And the next time that method is hit from navigation the breakpoint will be hit and you can see all the typical debugger stuff.
.cshtml (razor)
Keep in mind that all the razor engine does is prepare strings to be included in the response. It is a string factory. So if you want to debug the .cshtml the only chance you have is placing a breakpoint on the razor call which will be hit when navigated to. From there you can see things like the current values in the view model, session, etc.
javascript
The best chance you have to debug your javascript is going to be to fully render a page and then turn on the browser debugger from the client side to debug. You could (should?) also be writing tests and whatnot for your front end but that is a tangent. Chrome does a very good job of providing a debugger that you can set breakpoints in.
Overall, this is how you will debug your asp.net mvc application.
答案 1 :(得分:0)
您可以添加符号服务器,如图所示here,以进入VS 2012中的MVC4框架代码。