编辑并继续在 VS 2010 / ASP.Net MVC 2 中不起作用
尽管在我的 ASP.Net MVC 2 项目的 Web 选项卡上选中了“启用编辑并继续”,但实际上我无法在运行时更改源代码。例如,如果我尝试在调试器暂停时编辑控制器,则无法更改该文件(就像只读一样)。
我找到了相关帖子在 ASP.NET Web 项目中编辑并继续,但是
- 答案似乎表明我应该至少能够编辑代码,然后重新加载页面以查看结果。
- 我不知道 Web 应用程序和网站项目之间有什么区别
Although Enable Edit and Continue is checked on the Web tab of my ASP.Net MVC 2 project, I cannot in fact change the source code while running. For example, if I try to edit a controller while paused in the debugger, I cannot change the file (acts as if read only).
I found a related post Edit and continue in ASP.NET web projects, however
- The answers seem to suggest I should be able to at least edit the code, then reload the page to see the result.
- I don't know what the distinction is between a Web Application and Web Site projects
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
区别在于 Web 应用程序需要编译,而网站则在执行时动态编译(甚至是隐藏的代码)。
由于 ASP.NET MVC 使用 Web 应用程序,因此每次进行更改时都需要重新编译它,并且重新编译需要离开调试模式。事实上,您可以修改视图和部分而无需重新编译,但对于控制器逻辑,您始终需要重新编译。
为了加快速度,我建议您执行以下操作:
The distinction is that a Web Application needs to be compiled while a Web Site is compiled dynamically when executed (even the code behind).
As ASP.NET MVC uses a web application every time you make a change you need to recompile it and recompiling requires leaving the Debug mode. Indeed you could modify views and partials without the need of recompiling but for controller logic you always need to recompile.
To speed things up I would recommend you the following:
使用 Mvc,您无法编辑并继续。
但是,如果您通过 IISExpress 运行项目,那么无需在调试模式下运行项目,您就可以编辑代码隐藏,重建项目。然后刷新浏览器中的页面就可以了。
With Mvc you can't edit and continue.
But if you run the project by IISExpress, then without running the project in debug mode you can edit the codebehind, rebuild the project. And then refreshing the pages in browser would work.
除了@Darin 的回答之外,我不得不说我不喜欢在运行时更改代码的想法。
我认为我们应该有足够的纪律来编写反映预期结果的测试,编写代码然后进行实时测试。
尽管如此,我解决这个问题的方法是在浏览器中启动应用程序而不运行,进行更改,编译,然后刷新浏览器。
当然,这样我就没有逐步执行代码的好处,但我可以在需要时随时附加到工作进程。
Further to @Darin's answer I'd have to say I don't like the idea of being able to change code whilst running.
I think we should be disciplined enough to write a test that reflects the expected outcome, write the code and then test live.
Having said that though, the way I get around that is to start the application in a browser w/out running, making my changes, compiling and then refreshing the browser.
Of course then I don't have the benefit of stepping through code but I can attach to the worker process at any time I need to.
升级到VS2012。这确实支持 ASP.Net 项目的“编辑并继续”(从项目属性窗口中的“Web”选项卡)。尽管默认情况下它似乎并未启用!
Upgrade to VS2012. This does support Edit and Continue for ASP.Net projects (from the Web tab in the project properties window). Although it doesn't appear to be enabled by default!