Solved

Prevent webpage access using forms authentication

Posted on 2012-03-20
2
261 Views
Last Modified: 2012-03-21
Dear experts,

I have used the following two articles to setup forms security with roles.

http://support.microsoft.com/kb/301240
http://support.microsoft.com/kb/311495

Now I can use the roles to access or not give access, but I am wondering how to do this best.

I can show or hide menu items bases on the role, but a user can then still access pages if he/she manual enters the url manually. What is the best approach to prevent users from accessing a webpage?

Best regards,
MB
0
Comment
Question by:mark_norge
[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 Comments
 
LVL 7

Accepted Solution

by:
markmiddlemist earned 500 total points
ID: 37741103
There are 2 ways you can do this:

1 - In Code - In your page load handler include the line:

if (Roles.IsUserInRole("RoleName")) then
  Response.Redirect("/")
end if

or, the easier way is to use your web.config file - http://www.codeproject.com/Articles/2905/Role-based-Security-with-Forms-Authentication
0
 

Author Closing Comment

by:mark_norge
ID: 37746108
Both solution worked fine indeed. I prefer the second.
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

Suggested Solutions

Title # Comments Views Activity
c#, datatable, aspx 4 51
vb.net dbnull syntax 1 58
Click print button programmatically on print showdialog 1 24
VB.NET Parsing UDP Bytes 15 36
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

739 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