Hello,
I have an issue with my routing I have multiple areas one being a User area
Ideally in the URL when I click on a link I would like to see
www.exampe.com/user/login <- for when he/she clicks login
www.example.com/user/signup <- for when he/she clicks register
here is my area configuration file
public override void RegisterArea(AreaRegistrationContext context) { context.MapRouteLowercase( "User_default", "User/{controller}/{action}/{id}", new { action = "SignUp", id = UrlParameter.Optional } ); context.MapRouteLowercase( "Login", "User/{controller}/{action}/{id}", new { action = "Login", id = UrlParameter.Optional } ); }
but when I click signup I get
and when I click login I get
www.example.com/user/user/login
How can I make the URL as mentioned at the start of this thread?
Are you using MVC 5?
Looks like you are passing the controller as User and so – the following snippet:
User/{controller}/ will be matached as User/User.
So you would need only one – if this route is specific to User then, I believe you can try remove {controller} segment from above – or – if it is general route you can remove User segment and make Controller match with the User controller name.
I removed controller and now when I browse I get
The matched route does not include a ‘controller’ route value, which is required.
This is my controller
public class UserController : Controller { // // GET: /User/User/ public ActionResult SignUp() { return View(); } public ActionResult Login() { return View(); } }
context.MapRoute( "User_Login", "User/Login/{id}", new { controller = "User", action = "Login", id = UrlParameter.Optional } ); context.MapRoute( "User_Register", "User/Register/{id}", new { controller = "User", action = "Register", id = UrlParameter.Optional } );
I think these should work fine
perfect, cheers