0

I have Admin folder and User folder. and Login.aspx page inside user folder and Login.aspx page inside admin folder.

i have web.config in admin folder and user folder, please help me for loginUrl in web.config.

i use this code:

web.config (admin folder):

<authentication mode="Forms">
  <forms loginUrl="~/Admin/Login.aspx" timeout="2880"/>
</authentication>

web.config (user folder):

<authentication mode="Forms">
  <forms loginUrl="~/User/Login.aspx" timeout="2880"/>
</authentication>

but its not working and display error.

Babak Saeedi
  • 157
  • 4
  • 14
  • `authentication` can only be mentioned on the root config of a web application, if you want to implement folder level authentications, you need to map those folders as seperate virtual directories, but then you shall not be able to use Login of admin for user folder and vice versa. – Furqan Hameedi Apr 07 '13 at 13:37
  • please help me for Use The Multiple Login For Multiple Folders Using Web.config. – Babak Saeedi Apr 07 '13 at 13:40
  • duplicate of http://stackoverflow.com/questions/748287/how-to-override-change-formsauthentication-loginurl-in-certain-cases – Alexander Manekovskiy Apr 08 '13 at 15:07

1 Answers1

2

The <authentication> section can only be defined in the root web.config and cannot be overridden in child folders. If you want to have different login pages for different parts of the site you will have to implement it in your code. For example you could subscribe to the Authenticate event and based on the requested url decide to which Login page you want to redirect if the user is not authenticated.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928