Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC 3 - Different Login Page for Authorize Attribute

I have forms authentication wired up for my MVC 3 application. Normally when a request comes in that requires authentication, they are taken to my Login controller where they have to login.

However, I want a different view for this specific workflow because I plan on utilizing white labeling for my clients. Instead, I want them to go to a different endpoint in my Login controller to display my custom login view.

What options do I have to make this work?

like image 310
Brandon Avatar asked Jan 19 '23 08:01

Brandon


1 Answers

Can you elaborate on what you mean by white-label? What content will be changed and what will it depend on?

In your Web.config file look for

<system.web>
    <authentication mode="Forms">
        <forms loginUrl="/Login/Index" />
    </authentication>

Change the loginUrl attribute to what you want it to be. Then, on the login action, select the proper view to return.

You'll need some type of identifier to distinguish clients (subdomain, cookie or something). Use that to select the proper view to return.

like image 159
Omar Avatar answered Jan 30 '23 20:01

Omar