Solved

How do I setup new web pages to require authentication?

Posted on 2011-09-23
5
188 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
ID: 36591195
0
 
LVL 4

Accepted Solution

by:
guramrit earned 500 total points
ID: 36591313
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
ID: 36597262
remember now.   I put a web.config for my Admin folder.  Thanks.
0
 
LVL 16

Expert Comment

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

Author Comment

by:lapucca
ID: 36597552
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
A short film showing how OnPage and Connectwise integration works.

914 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

16 Experts available now in Live!

Get 1:1 Help Now