为什么不,当我调试我的ASP.NET MVC应用程序中的Application_Start()事件火? [英] Why does not the Application_Start() event fire when I debug my ASP.NET MVC app?
问题描述
目前,我有我的的Global.asax.cs
文件下列程序:
I currently have the following routines in my Global.asax.cs
file:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Arrangement", action = "Index", id = "" }
);
}
protected void Application_Start()
{
RegisterRoutes(RouteTable.Routes);
// Debugs the routes with Phil Haacks routing debugger (link below)
RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes);
}
路由调试 ...
当我打 F5
,应用火了,除非我有一个名为的Index.aspx
视图〜/查看/主页/
文件夹中,我得到了查看丢失的错误信息,虽然我已经重新定义的默认路由并删除了 HomeController的
。我希望得到的路由调试器,如果没有,至少对的请求〜/查看/配置/的Index.aspx
在的RegisterRoutes(Routetable.Routes)的断点。在调试的时候
从不打
When I hit F5
, the application fires up and unless I have a view named Index.aspx
in the ~/Views/Home/
folder, I get the "View missing" error message, although I have re-defined the default route and removed the HomeController
. I would expect to get the routing debugger, and if not that at least a request for ~/Views/Arrangement/Index.aspx
.
A breakpoint on RegisterRoutes(Routetable.Routes);
is never hit when debugging.
我曾尝试新建,改建,重新启动VS,清洗,再等重建,但似乎没有任何工作。为什么不应用程序运行code的当前版本?
I have tried building, rebuilding, restarting VS, cleaning, rebuilding again etc, but nothing seems to work. Why doesn't the application run the current version of the code?
推荐答案
我发现这个问题:
这MVC应用程序是一个更大的解决方案,其中我在设置另一个项目搭建一个x86环境(我运行x64)的一个点的一部分。当我这样做,显然是所有其他项目 - 即使是后来添加的 - 被设置为不建立在按Ctrl + Shift + B
,我想这就是为什么调试器没有打我的断点。
This MVC application was part of a larger solution, in which I had at one point set another project to build for an x86 environment (I'm running x64). When I did that, apparently all other projects - even those added later - were set not to build on Ctrl+Shift+B
, and I suppose that's why the debugger didn't hit my breakpoint.
解决方案:
走进解决方案生成属性(右键单击解决方案,选择属性,然后选择建立在左边的菜单上),并把检查在Build复选框在列表中的项目名称旁边。
Go into the solution build properties (right-click Solution, select properties, and select Build on the menu on the left), and put a check in the Build checkbox next to the project name in the list.
这篇关于为什么不,当我调试我的ASP.NET MVC应用程序中的Application_Start()事件火?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!