Solved

Visual Studio - Exlcuding a page from redirecting to login

Posted on 2008-10-23
4
165 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 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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
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…

729 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