2011-04-18 37 views
1

如何配置RemoveAttribute以使用此类路由?ASP.NET MVC RemoteAttribute:无法找到远程验证的URL

context.MapExtendedRoute("ValidateSomething", 
           "some-where/validate/{propName}", 
           new { Controller = "SomeWhere", Action = "ValidateSomeRouteKey" }); 

当我通过上述路线名称RemoteAttribute构造函数,InvalidOperationException发生。但是,如果路由定义中没有propName,并且以查询字符串的形式传递参数,那么它的作用就像魅力一样。

在此先感谢;)

回答

1

您需要的{} PROPNAME参数添加到您的路线,让你可以在你的控制器访问它。在下面的例子中,我已经选择了它。

context.MapExtendedRoute("ValidateSomething", 
          "some-where/validate/{propName}", 
          new { Controller = "SomeWhere", Action = "ValidateSomeRouteKey", propName = UrlParamter.Optional }); 
+0

不,我在测试之前测试过这个) – Sadegh 2011-04-18 12:54:03

+0

呵呵,如何告诉RemoteAttribute这样做? – Sadegh 2011-04-19 08:01:25