Sadegh
Sadegh

Reputation: 4341

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

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

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

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;)

Upvotes: 1

Views: 2140

Answers (1)

Paige Cook
Paige Cook

Reputation: 22555

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 });

Upvotes: 1

Related Questions