1

I m creating an Mvc application . I have some issue .

I am getting url

http://localhost:2355/Home/Contract?Length=4

I want my url as

http://localhost:2355/Home/Contract

routes.MapRoute(
  name: "Default",
  url: "{controller}/{action}",
  defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } 
);

what is problem in my route mapping

  • Could you post the `ActionLink` or `RouteLink` signature that you are using that is yielding this URL? – NightOwl888 Jan 30 '16 at 08:23
  • 3
    It means your using the wrong overload of `@Html.ActionLink()`. Show your code! –  Jan 30 '16 at 08:26
  • actually i m not using actionLink or routeLink ,used only Maproute() method. – Rashi Gupta Jan 30 '16 at 09:40
  • What? How are you generating that url is you not using `ActionLink` or `RouteLink`? `MapRoute` has nothing to do with it (it just defines a route, it does not generate a url) –  Jan 30 '16 at 09:43
  • 1
    Check this answer for comparison: http://stackoverflow.com/questions/4357856/razor-actionlink-autogenerating-length-7-in-url – gardarvalur Jan 30 '16 at 13:45
  • Unless you show us how the URL is generated, we cannot really be of help. – Tommy Jan 30 '16 at 16:01

1 Answers1

0

If you're using @Html.ActionLink() you should try try these ones.

@Html.ActionLink("MyAction", "MyController", new { }, new { @Class="class-name"})

with Areas

@Html.ActionLink("MyAction", "MyController", new { }, new {@Area = "MyArea" @Class="class-name"})

Sendind data

@using (Ajax.BeginForm("MyAction", "MyController", new {  }, new AjaxOptions { HttpMethod = "POST" }, new { @Area = "MyArea" }))

Sending data with no Area

@using (Ajax.BeginForm("MyAction", "MyController", new AjaxOptions { HttpMethod = "POST" }));

Besides that, you can check the url which @gardarvalur has posted. I hope it helps you.

Rodrigo de Farias
  • 657
  • 2
  • 8
  • 20