Link to home
Start Free TrialLog in
Avatar of sproctor722
sproctor722

asked on

Visual Studio - Exlcuding a page from redirecting to login

The following question was just answered:

Question: I have a web application created using Visual Studio 2008.  I want users to be denied access to the site if they are not logged in first.  I want the user trying to access a page without logging in to be redirected to the login page.

Now I need to know how to exclude a page from redirecting to the login page.  I have a page for password recovery that I would like the users to have access to if they have forgotten their password.
Avatar of Snarf0001
Snarf0001
Flag of Canada image

in your web.config file, under the primary <configuration> node, add something like the following:

  <location path="myPath/PasswordRecovery.aspx">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
    </system.web>
  </location>
Avatar of sproctor722
sproctor722

ASKER

Adding this gives access to all pages.  I want to exclude the PasswordRecovery page and password protect the other pages.
No, normallly the allowusers goes in the primary system.web section, as you did in the last question you mentioned.
Outside of the normal system.web, you can override that behavriou by adding <location> tags.
Generally these go at the bottom of the web.config, or after the system.web part.
When you add a new section in, you can override the behavior on a single page or an entire folder.
IN the example above, all pages will still be restricted, but the override would be applied to a page called PasswordRecovery.aspx, and that page alone.
ASKER CERTIFIED SOLUTION
Avatar of Snarf0001
Snarf0001
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial