user1202839
user1202839

Reputation: 375

Razor Url.Action and mvc routing

Given this: in index.cshtml:

 a href="@Url.Action("Create", "Request")">Create Request</a>

global.asax:

  routes.MapRoute(
                "Request",
                "request/{action}",
                new {controller="Request",action="Create" }
                );

It redirects to this url: http://localhost:16997/request. How would I make it go to http://localhost:16997/request/create ? If I just type the 'create' in the url, it displays the Content of the create method appropriately.

Upvotes: 1

Views: 1389

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038840

Remove the action default value in your route definition:

routes.MapRoute(
    "Request", 
    "request/{action}", 
    new { controller = "Request" } 
);

Upvotes: 1

Related Questions