I have this code in a JavaScript function:
var url = '@Url.Action(MVC.Membership.User.ActionNames.Update, MVC.Membership.User.Name)';
url += "?userName=" + userName;
ul.append("<li><a href=" + url + "\>" + userName + "</a></li>");
Membership is an Area. I’m using T4MVC to refer to Controller and Action names to avoid magic strings… 🙂
This JavaScript code is part of View that resides in the Membership Area.
UserController is decorated this way:
[RouteArea("Membership")]
public partial class UserController : BaseController
and the Action method is this one:
[GET("Users/Update/{userName}")]
public virtual ActionResult Update(string userName)
The route I get in the link is this:
http://localhost:8087/membership/User/Update?userName=leniel
I expected it to be:
http://localhost:8087/membership/users/update?userName=leniel
So my question is: why the link is not in lowercase since all other links in the app are being generated with lower case letters? Is this not supported or am I forgetting some config related to AttributeRouting or the Area setup?
After the feedback from AttributeRouting creator… turns out it was my bad.
Now I understand the problem…
If I do this:
The URL is generated correctly:
but if I do this:
I get this:
It’s clear that I need to pass the roleName parameter.