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路線做可選正則表達式的羣體?
謝謝...我看到那篇文章。我希望能夠通過.NET 2程序集的反射來實現它,但是基類會殺死它......無論如何,我確實使用了類似的解決方案 - 我定義了自己的StopRoutingRoute,但我必須創建一個單獨的3.5組裝來做到這一點。 –