Web config

G

Guest

have a web app where one page Default.aspx should be publicly accessable and
another Admin.aspx restricted to a certain local group. When I am on
Default.aspx. There is link which suppose to take me Admin.aspx but I want
too give security to that page and always it jumps me to Login.aspx page.
How can I do that.

How can I do this in a web.config? Can I specify different authorization
settings per file?
 
C

Chris Fulstow

have a web app where one page Default.aspx should be publicly accessable and
another Admin.aspx restricted to a certain local group. When I am on
Default.aspx. There is link which suppose to take me Admin.aspx but I want
too give security to that page and always it jumps me to Login.aspx page.
How can I do that.

How can I do this in a web.config? Can I specify different authorization
settings per file?

Hi Bobby

You can add these settings to you web.config:

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

<location path="Admin.aspx">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>

If you need different settings for other files then you can add more
<location> settings.

It's also possible to do the same thing using code, with something
like:

If Not User.IsInRole("Administrators") Then
Response.Redirect("Login.aspx")
End If

Chris
 

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,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top