2013-12-23 24 views
1

我是MVC4中的newby。MVC4中的事件处理程序

protected void Application_Start() 
{ 
    AreaRegistration.RegisterAllAreas(); 

    //GlobalConfiguration.Configure(WebApiConfig.Register); 
    FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); 
    RouteConfig.RegisterRoutes(RouteTable.Routes); 
    BundleConfig.RegisterBundles(BundleTable.Bundles); 
} 

我想写一个处理程序,当我写.../Stackoverflow但总是Stackoverflow控制器工作。 如何停止调用Stackoverflow控制器?我只想打电话给处理程序。

我将下面的语句添加到web.config中。

<add name="MyHandler" verb="*" path="/Stackoverflow " type="Library.MyHander"/> 

回答

2

你需要忽略这条路线,所以在RegisterRoutes方法,加入这一行:

routes.IgnoreRoute("Stackoverflow");