Solved

How do I setup new web pages to require authentication?

Posted on 2011-09-23
5
187 Views
Last Modified: 2012-05-12
Hi, I'm using asp.net and C# 3.5.  
I created an asp.net web application that requires membership authentication through login screen.  There was only one page after use is authenticated in.  I now need to create several pages and they all should only allow access after the user is authenticated.  However, I forgot how I set that up.  Can someone tell me in quick steps on how to do this for the new pages?  Thank you.
0
Comment
Question by:lapucca
  • 2
  • 2
5 Comments
 
LVL 16

Expert Comment

by:disrupt
Comment Utility
0
 
LVL 4

Accepted Solution

by:
guramrit earned 500 total points
Comment Utility
You can use web.config to implement this type of security.
You can do it in two ways.
1. Folder level
2. File level

I guess, you need file level security. To implement this, see following code, it's added in web.config

 
<location path="AddStatusReport.aspx">
	<system.web>
		<authorization>
			<deny users="?" />
			<allow users="*" />
		</authorization>
	</system.web>
</location>
<location path="EmployeeRatingReport.aspx">
	<system.web>
		<authorization>
			<allow roles="Administrators" />
			<deny users="*" />
		</authorization>
	</system.web>
</location>
<location path="DailyStatusReport.aspx">
	<system.web>
		<authorization>
			<allow roles="TeamLeads" />
			<deny users="*" />
		</authorization>
	</system.web>
</location>

Open in new window


add this code before closing tag of <configuration> ie. at the end of file. and modify page names according to yours.

? : anonymous users
* : all users

for more details, see : Setting authorization rules for a particular page or folder in web.config
0
 

Author Closing Comment

by:lapucca
Comment Utility
remember now.   I put a web.config for my Admin folder.  Thanks.
0
 
LVL 16

Expert Comment

by:disrupt
Comment Utility
Did you look at the link I gave? Showed how to setup the web.config...
0
 

Author Comment

by:lapucca
Comment Utility
sorry but I didn't see your posting but now I look at the link it's not really what I need  I would have give you some points if I saw the link but sorry i missed it.  Gu's link gave more examples and is what I need.  A web.config for the folder.  Thank you.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now