asp.net mvc的它处理所有的请求? - IIS 7集成模式 [英] asp.net mvc does it handle all requests? - iis 7 integrated mode

查看:85
本文介绍了asp.net mvc的它处理所有的请求? - IIS 7集成模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用IIS 7 asp.net的MVC运行使用集成模式的网站建成。我注意到,当我在mysite.com/test.html型我找回IControllerFactory没有名为test.html的控制器返回的控制器。

I have a site built using asp.net mvc running on IIS 7 using integrated mode. I noticed when I type in mysite.com/test.html I get back The IControllerFactory did not return a controller for a controller named 'test.html'.

我应该已经得到了一个404错误,这应该的被IIS7静态处理程序服务。

What I should have gotten was a 404 error and this should of been served by the IIS7 Static Handler.

现在我想知道,是否在asp.net mvc的处理程序服务的一切吗? (CSS,图像,zip档案),而不是静态文件处理程序。

Now what I am wondering, does the asp.net mvc handler serve everything? (css, images, zip archives) instead of the static file handler.

如果是的话那么有没有一种办法可以解决这个使静态处理器将成为具有扩展名的文件。否则,这似乎是一个很大的性能问题。

If it does then is there a way I can work around this so the Static handler will serve files with extensions. Otherwise this seems like a big performance issue.

推荐答案

默认情况下,ASP.NET MVC将处理所有的请求,因为布线设计处理任何路径。您可以通过使用 IgnoreRoute 方法,像这样(在Global.asax中):

By default, ASP.NET MVC will handle all requests, since the routing is designed to handle any paths. You could specifically exclude certain paths by using the IgnoreRoute method, like this (in Global.asax):

public static void RegisterRoutes(RouteCollection routes)
{
    // This is already added by MVC
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

    // Ignore any htm files
    routes.IgnoreRoute("{filename}.htm");

    // Other routes
    // ...
}

我怀疑这还是会导致请求通过ASP.NET会(虽然我怀疑他们会落空的相当快)。如果这是一个问题,你可以尝试改变web.config设置在所有未通过要求ASP.NET:

I suspect this will still result in requests going through ASP.NET (though I suspect they'll "fall through" quite quickly). If this is a problem, you could try changing the web.config settings to not pass the requests to ASP.NET at all:

<modules runAllManagedModulesForAllRequests="false" />

不过你需要设置正是你想要去通过ASP.NET哪些请求。

However you'll need to set up exactly which requests you want to go through ASP.NET.

这篇关于asp.net mvc的它处理所有的请求? - IIS 7集成模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆