how to limit authorization in admin subfolder from web.config

F

Frenny Thomas

I'm in quite of a dilemma, and for the first time: all the articles and
discussion forums on the 'net hasn't helped me get rid of my page errors
:(

I have my web.config file in the root directory. I have a subdirectory
called /admin/ underneath it. I want all users to be able to view any
page in the root directory. If a user tries to access any page in the
/admin/ subfolder, I want him/her to be redirected to a login page
(located in the subfolder itself).

I have tried two methods of doing the job, but neither have worked. Can
anyone give me any suggestions/explanations??

Method 1
------------------------------------------------------------------------
--------
<configuration>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true"/>
<authorization>
<allow users="*"/>
</authorization>
</system.web>


<location path="admin">
<system.web>
<customErrors mode="Off"/>
<compilation debug="true"/>
<authentication mode="Forms">
<forms name="frmLogin"
loginUrl="login.aspx">
</forms>
</authentication>
<authorization>
<deny users ="?" />
</authorization>
</system.web>

</location>

</configuration>

Method 2 [After I moved the login.aspx page back up to the root
directory]
------------------------------------------------------------------------
--------
<configuration>
<system.web>
<customErrors mode="Off" />
<compilation debug="true" />
<authentication mode="Forms">
<forms name="frmLogin"
path="/"
loginUrl="login.aspx"
protection="All"
timeout="20"></forms>
</authentication>
<authorization>
<allow users="*" />
</authorization>
</system.web>
<location path="admin">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>
</configuration>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top