Solved

How do I setup new web pages to require authentication?

Posted on 2011-09-23
5
193 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
[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
  • 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

Independent Software Vendors: 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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

726 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