Reputation: 8932
I'm missing something very trivial here, in all the examples this works in a razor page:
'@Url.Action("GetUserUnits", "MvcAccount")'
Which should translate to, which I want to use in javascript:
/MvcAccount/GetUserUnits
But in stead it generates this:
/?action=GetUserUnits&controller=MvcAccount
Why? I must be doing something wrong?
Upvotes: 0
Views: 141
Reputation: 579
IF you want to go to -> /MvcAccount/GetUserUnits
Use
@Html.ActionLink("nameOfyourLink", "GetUserUnits", "MvcAccount")
[displayName] [Action] [Controller]
Upvotes: -1
Reputation: 9755
Bascially you have something messed up with your routings. @Url.Action
cannot match routing to your action.
This can be caused by lack of default routing defined. Usually you should have it registered on application start in your Global.asax.cs
file.
For example it could look like this:
protected void Application_Start()
{
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = "" }
);
}
Upvotes: 2