?
Solved

Visual Studio - Exlcuding a page from redirecting to login

Posted on 2008-10-23
4
Medium Priority
?
167 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 23

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 23

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 23

Accepted Solution

by:
Snarf0001 earned 500 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

Basic Security of Your VPC

So, you’ve got this shiny new VPC and a fancy new application configured on your EC2 servers ready to go. This application is only accessible from your computer, which is great for security, but you need your users to be able to access it! So, what’s the easiest way to do this?

Question has a verified solution.

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

777 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