We are using the ASP.NET MVC Futures project (Microsoft.Web.Mvc) to enable an MVC 3 application to use RESTful routes. This application has been working perfectly under MVC 1 and its related System.Web.Mvc.Resources.dll assembly for the same functionality.
We are registering the routes as such:
routes.MapResourceRoute("MyController", "{MyItemId}");
Which should give us routes like:
/MyController
/MyController/{MyItemId}
/MyController/{MyItemId}/EditForm
/MyController/CreateForm
We get three of the four routes that are valid -- the second on that list (/MyController/{MyItemId}) returns an error:
Server Error in '/' Application.
The RouteData must contain an item named 'action' with a non-empty string value.
When I try appending ?action=Details or other ways of injecting an action parameter to the URL, I get 404 errors. It looks like the WebEnabledApi attribute in the Futures code changed significantly - anyone else having these issues, and have a solution?
The default route is based on "controller/action/id", as you're just passing the id and not the action, it will give you 404 error.
routes.MapRoute("Default", "{controller}/{action}/{id}",
new
{
controller = "Home",
action = "Index",
id = UrlParameter.Optional
});
I believe you're trying to call the details action.
If you do have a action on the controller, using the default route might work:
MyController/Details/{MyItemId}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With