2010-07-28 35 views
1

有誰知道如何確保存在的文件和目錄不會路由到.NET MVC(如果它們存在於根目錄中)?如何將文件和目錄路由到ASP.NET MVC

與Zend框架,這在.htaccess完成,像這樣:

RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 

這是如何實現的IIS?

這裏是一個用例: 如果my_ir存在於web_root中並且用戶訪問domain.com/myDir,myDir不會路由到MVC,而是將用戶發送到該目錄。

回答

1

有了URL路由這應該在默認情況下發生,但你可以在你的RegisterRoutes方法在Global.asax中添加:

Sub RegisterRoutes(ByVal Routes As RouteCollection) 

Routes.RouteExistingFiles = False 

這些也可以幫助:

' Ignore Routes 
    Dim Ir As Route = New Route("{resource}.axd/{*pathInfo}", New StopRoutingHandler()) 
    Routes.Add(Ir) 

    Dim ignore1 As Route = New Route(("favicon.ico"), New StopRoutingHandler()) 
    Routes.Add(ignore1) 

    Dim ignore2 As Route = New Route(("Telerik.RadUploadProgressHandler.ashx/{*pathInfo}"), New StopRoutingHandler()) 
    Routes.Add(ignore2) 

End Sub