Forum Moderators: open

Message Too Old, No Replies

web.config problem

         

andrewsmd

3:16 pm on Jul 14, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have an administrative side on a website that requires a login. I am using the asp.net membership provider to do implement and manage my roles. Here is what my folder structure looks like
Site/admin
site/admin/folder1
site/admin/folder1/file1
site/admin/folder1/file2
site/admin/folder1/web.config
site/admin/folder2
site/admin/folder2/file3
site/admin/folder2/file4
site/admin/folder2/web.config
site/admin/permissionsError.aspx
site/admin/login.aspx

Now within those web.config files i have this

<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="../permissionsError.aspx" />
</customErrors>
<authorization>
<deny roles="Dealer" />
<allow roles="SiteAdmin" />
<allow roles="DealershipAdmin" />
<allow roles="SuperAdmin" />
</authorization>
</system.web>
</configuration>

as you can see anyone with the role Dealer is not allowed to see those pages. I am trying to redirect them to the file
site/admin/permissionsError.aspx but it keeps redirecting to login.aspx. Does anyone know why? Thanks,

marcel

3:44 pm on Jul 14, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



login.aspx is probably set in your authentication node:

<authentication mode="Forms">
<forms defaultUrl="Default.aspx" loginUrl="~/Login.aspx" slidingExpiration="true" timeout="20">
</forms>
</authentication>

In this page you could check Request.IsAuthenticated to see if the user is logged in. If this is the case, you can redirect them to the permissionsError page.

andrewsmd

4:09 pm on Jul 14, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That was exactly my problem. Thanks very much. I'm new to asp coming from php so I'm not used to not being in control of all of these roles and permissions that are generated for me.