Reputation: 798
I'm developing an admin panel and I have created a new area called "Admin" to start. Now in my AdminAreaRegistration.cs file the routing is just like this
context.MapRoute(
"Admin_default",
"Admin/{controller}/{action}/{id}",
new { controller = "Index", action = "Index", id = UrlParameter.Optional }
);
So i can reach the admin panel with http://{mydomain}/Admin/
And I have 2 Controllers. IndexController to manage the login, signin, etc. UserController to manage listing users, adding new user, etc.
When i try to access user's list the url will look like that http://{mydomain}/Admin/User/List/ this is pretty good looking url. But when i try to access Signin for a new admin the url will be like this: http://{mydomain}/Admin/Index/Signin/
But i didn't like the 2nd url. Can i access the index controller like http://{mydomain}/Admin/Signin/ and the others like first one.
And how would you approach this kind of situation? I really want to do this in right way
Upvotes: 0
Views: 85
Reputation: 1073
For your Signin url, if you have a Signin Action set-up in your Indexcontroller, set-up a route before your "Admin_default" route like this:
context.MapRoute(
"Admin_Signin",
"Admin/SignIn",
new { controller = "Index", action = "Signin" }
);
You can then link to this action with ActionLinks like so:
@Html.ActionLink("Sign-in here", "Signin", new { controller = "Index", action = "Signin" })
Upvotes: 1