将ASP.NET MVC项目调试到框架源代码中

时间:2023-01-18 23:53:48

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?

如何调试ASP.NET MVC源代码?我想在PHP或Java Frameworks中很容易调试到框架源代码,对吧?通常它直接进入框架源代码。 ASP.NET MVC怎么样?

btw, .NET is fully open-source? So debugging should now be the same as in PHP and Java?

顺便说一句,.NET是完全开源的吗?那么现在调试应该和PHP和Java一样吗?

2 个解决方案

#1


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.

几乎所有在asp.net mvc上完成的工作都是在visual studio中完成的,所以我假设你正在使用它。在Visual Studio中调试mvc项目时,需要记住几个问题。

c# (server side)

c#(服务器端)

This is pretty straight forward. Ensure that your project is running

这很简单。确保您的项目正在运行

将ASP.NET MVC项目调试到框架源代码中

And set a breakpoint

并设置一个断点

将ASP.NET MVC项目调试到框架源代码中

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.

请记住,所有剃须刀引擎都会准备要包含在响应中的字符串。这是一个字符串工厂。因此,如果你想调试.cshtml,你唯一的机会就是在剃刀调用时放置一个断点,这个断点将在导航时被点击。从那里,您可以看到视图模型,会话等中的当前值。

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.

调试javascript的最好机会是完全呈现页面,然后从客户端打开浏览器调试器进行调试。你可以(应该?)也为你的前端编写测试和诸如此类的东西,但这是一个切线。 Chrome在提供可以设置断点的调试器方面做得非常好。

Overall, this is how you will debug your asp.net mvc application.

总的来说,这是你将如何调试你的asp.net mvc应用程序。

#2


You can just add the symbol servers as shown here to step into MVC4 framework code in VS 2012.

您可以添加符号服务器,如此处所示,以进入VS 2012中的MVC4框架代码。

#1


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.

几乎所有在asp.net mvc上完成的工作都是在visual studio中完成的,所以我假设你正在使用它。在Visual Studio中调试mvc项目时,需要记住几个问题。

c# (server side)

c#(服务器端)

This is pretty straight forward. Ensure that your project is running

这很简单。确保您的项目正在运行

将ASP.NET MVC项目调试到框架源代码中

And set a breakpoint

并设置一个断点

将ASP.NET MVC项目调试到框架源代码中

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.

请记住,所有剃须刀引擎都会准备要包含在响应中的字符串。这是一个字符串工厂。因此,如果你想调试.cshtml,你唯一的机会就是在剃刀调用时放置一个断点,这个断点将在导航时被点击。从那里,您可以看到视图模型,会话等中的当前值。

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.

调试javascript的最好机会是完全呈现页面,然后从客户端打开浏览器调试器进行调试。你可以(应该?)也为你的前端编写测试和诸如此类的东西,但这是一个切线。 Chrome在提供可以设置断点的调试器方面做得非常好。

Overall, this is how you will debug your asp.net mvc application.

总的来说,这是你将如何调试你的asp.net mvc应用程序。

#2


You can just add the symbol servers as shown here to step into MVC4 framework code in VS 2012.

您可以添加符号服务器,如此处所示,以进入VS 2012中的MVC4框架代码。