views:

42

answers:

1

Hi Guys,

I have developed an application in ASP.NET 3.5 which utilizes the Membership and Roles Providers and Forms Authentication to manage user access and profiles.

There are various area's of this application that are only to be used by an admin users whom login using their email and password and the rest of the users log in using their telephone number and password via their iPhone.

For simplicities sake, I would like to have two different login pages, one that is formatted for the iPhone and performs the correct validation for users adding a telephone number and the other for the application administrators.

I want to redirect the user to their respective login page based on which folder they are attempting to access. For example say I have an application structure like this -

/Admin
/Couriers
/Customers
/Whatever
Default.aspx
iPhoneLogin.aspx
adminLogin.aspx
Web.config

I want to be able to redirect users who go to www.myapp.com/Whatever to iPhoneLogin.aspx and users to go to www.myapp.com/Admin to adminLogin.aspx

Can anyone suggest a way of accomplishing this through the web config if possible?

If not, has anyone any other suggestions on how to accomplish this?

Thanks, Tristan

+1  A: 

When the FormsAuthentication provider redirects the user to the login page specified in your web.config, the previous URL will be passed as the "ReturnUrl" querystring parameter. I would designate 1 of your 2 log-in pages as the primary one and have it be the one specified as the login page in the web.config. On it's Page.Load, check to see if the ReturnUrl parameter is for the other secured folder. If so, redirect the user to the other login page. Just make sure that you send over the ReturnUrl parameter as well.

David
@ David - Thanks, this one sounds like it might be handy enough to implement. I am also looking into the possibility of using Location Element in the Web.config File to set different loginUrl
TGuimond
@ David - I ended up going with the solution you suggested. It's not ideal having the redirect but it works sufficiently! Thanks for the help!
TGuimond