File level permissions using the web.config & forms authentication

S

Stu Lock

Hi,

Is there a way of requiring a log in for individual asp.net pages rather
than securing a entire directory. I have a web app where there are 100+
pages but only 2 need to be password protected. I am currently using forms
authentication to block the entire folder:

<authentication mode="Forms">
<forms name=".MYCOOKIE"
loginUrl="login.aspx"
protection="All"
timeout="30"
path="/"/>
</authentication>
<authorization>
<deny users="?" />
</authorization>

Thanks in advance,

Stu
 
G

Girish Bharadwaj

Can you put them in a sub directory and use <location> tag to do the
authentication?
 
S

Stu Lock

Can you put them in a sub directory and use said:
authentication?

I could but I was looking for a 'nicer' way to do it. The pages are part of
quite a large content management system with hierachical menus. I would have
preferred not having to mess about with changing the menu links to pages if
they are to be secured.

If I can't do it by configuring the web.config file I'll probably go with
something like this in the pageload area:

If Not IsNumeric(Page.User.Identity) Then
Response.Redirect("logon.aspx?ReturnUrl="MyPage.aspx")

Thanks for the response anyway.

Stu
 
G

Guest

Would this work:

<authorization>
<allow users="*"/>
</authorization>

<location path="folder/filename1.aspx">
<system.web>
<authorization>
<allow roles="user"/>
<deny users="*"/>
</authorization>
</system.web>
</location>

<location path="folder/filename2.aspx">
<system.web>
<authorization>
<allow roles="user"/>
<deny users="*"/>
</authorization>
</system.web>
</location>

I hope that helps!

Charles
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top