开发者

ASP.NET MVC RemoteAttribute: No url for remote validation could be found

开发者 https://www.devze.com 2023-02-27 06:13 出处:网络
How to configure RemoveAttribute to work with routes like this one? context.MapExtendedRoute(\"ValidateSomething\",

How to configure RemoveAttribute to work with routes like this one?

 context.MapExtendedRoute("ValidateSomething",
                                 "some-where/validate/{propName}",
                                 new { Controller = "SomeWhere", Action = "ValidateSomeRouteKey开发者_JAVA技巧" });

When I pass above route name to RemoteAttribute constructor, an InvalidOperationException occurs. But works just like a charm when there is no propName in route definitions and parameter passed as querystring.

Thanks in advance;)


You need to add the {propname} parameter to your route, so that you can access it in your controller. In the example below I have made it optional.

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

精彩评论

暂无评论...
验证码 换一张
取 消