Катерина
Катерина

Reputation: 404

ASP MVC routing issue

I have a few situations with my routing I guess. I am trying to use a Url.Action for this, but it is not working as I hoped. Probably something small I just miss?

I am sitting on http://localhost:63061/service, inside the UI there is a button. Once I click on that I want it to bring me to http://localhost:63061/partdispatch

Seems quite simple right? but for some reason I just keep having the wrongs routes.

onclick="window.location.href = '@Url.Action("PartDispatch", "mainmenu")';"

routing settings:

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

Upvotes: 1

Views: 51

Answers (2)

Basanta Matia
Basanta Matia

Reputation: 1562

This is how I do,

onclick="window.location = "../PartDispatch/Index";"

Or-else

onclick="window.location.href = '@Url.Action("Index", "PartDispatch")';"

Hope it helps :)

Upvotes: 1

Катерина
Катерина

Reputation: 404

Ok, Basanta Matia mentioned very simple whatever I wish to do. Calling the index. so I changed the action.url to '@Url.Action("index", "partdispatch")'and that was the only thing I had to do. quite ashamed. Really need to learn this: https://www.google.nl/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=url.action+documentation&*

Upvotes: 0

Related Questions