Solved

How do I setup new web pages to require authentication?

Posted on 2011-09-23
5
191 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

685 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