Solved

Visual Studio - Exlcuding a page from redirecting to login

Posted on 2008-10-23
4
163 Views
Last Modified: 2013-11-26
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.
0
Comment
Question by:sproctor722
  • 3
4 Comments
 
LVL 22

Expert Comment

by:Snarf0001
ID: 22789963
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>
0
 

Author Comment

by:sproctor722
ID: 22790406
Adding this gives access to all pages.  I want to exclude the PasswordRecovery page and password protect the other pages.
0
 
LVL 22

Expert Comment

by:Snarf0001
ID: 22790527
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.
0
 
LVL 22

Accepted Solution

by:
Snarf0001 earned 125 total points
ID: 22790559
ie:

<configuration>
  <configSections />--all the data in there
  <system.web />--all the data in there, here is where your primary restriction is enforced
                           --with the forms authentication
  <system.codedom />--all the data in there
  <runtime />--all the data in there

<!--here you enter an override outside of the normal system.web for a specific page / folder -->  
<location path="myPath/PasswordRecovery.aspx">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
    </system.web>
  </location>


</configuration>
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB.NET 2008 - Windows Protected Your PC 7 41
Dot Net 4.6.1 installation fails on W2012 R2 server 14 38
JSON  parse help 7 40
SQL Server Connection String through a VPN 8 55
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question