Nothing
Nothing

Reputation: 2642

How to make an alias in the url of asp.net MVC

This is my URL web site : "www.mysite.com". If I want to log in to have an administrator lever, I have to go : "www.mysite.com/Account/LogOn".

Can everyone can tell me, how can I use only "www.mysite.com/administrator" to log in to administrator level of my site.

Upvotes: 1

Views: 3110

Answers (2)

user596075
user596075

Reputation:

What you are looking for is to the RouteCollection.MapRoute() method to define your custom route. Something like this would suffice:

routes.MapRoute(
    "Admin", // Route name
    "Administrator", // URL with parameters
    new { controller = "Account", action = "LogOn" } // Parameter defaults
);

What this does is translates www.mysite.com/adminsistrator to your Account controller with the LogOn action.

Upvotes: 2

Ashok Padmanabhan
Ashok Padmanabhan

Reputation: 2120

You can set the Authorize attribute on your Index action in the Administrator controller so if someone goes to /Admininistrator/Index or /Administrator then they wil be redirected to the the logon page and then once logged in back to the admin page.

Upvotes: 1

Related Questions