2011-08-04 19 views
1

我遇到了可選正則表達式子句(\ .ashx)的問題?在ASP.NET MVC路線MVC路由中的可選正則表達式組?

routes.IgnoreRoute("resizer\\.debug(\\.ashx)?"); 
routes.IgnoreRoute("[^?]+\\.(psd|bmp|gif|exif|png|tif|tiff|tff|jpg|jpeg|jpe|jif|jfif|jfi)(\\.ashx)?"); 

我得到的錯誤

The route URL cannot start with a '/' or '~' character and it cannot contain a '?' character. 
Parameter name: routeUrl 

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ArgumentException: The route URL cannot start with a '/' or '~' character and it cannot contain a '?' character. 
Parameter name: routeUrl 

[ArgumentException: The route URL cannot start with a '/' or '~' character and it cannot contain a '?' character. 
Parameter name: routeUrl] 
    System.Web.Routing.RouteParser.Parse(String routeUrl) +21953 
    System.Web.Routing.Route.set_Url(String value) +12 
    System.Web.Routing.Route..ctor(String url, IRouteHandler routeHandler) +9 
    System.Web.Mvc.RouteCollectionExtensions.IgnoreRoute(RouteCollection routes, String url, Object constraints) +106 
    System.Web.Mvc.RouteCollectionExtensions.IgnoreRoute(RouteCollection routes, String url) +6 
    MvcApplication2.MvcApplication.RegisterRoutes(RouteCollection routes) in C:\Users\Administrator\Documents\resizer\Tests\Hidden\MvcApplication2\Global.asax.cs:15 
    MvcApplication2.MvcApplication.Application_Start() in C:\Users\Administrator\Documents\resizer\Tests\Hidden\MvcApplication2\Global.asax.cs:29 

如何在MVC路線做可選正則表達式的羣體?

回答