Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 11th, 2006, 07:40 PM
Authorized User
 
Join Date: Feb 2006
Location: , , .
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default accessing pages with roles authorization

Hi,

i have set three roles in my application, one role for adminstration, another for managers and the final one for normal users. some pages are allowed for some roles but not for others. for instance there are a number of pages that can be accessed by the managers but not the normal users. the problem here is when the normal user attempt to enter the manager pages the system redirect the user to an error page which says:

The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /ECBS/login.aspx


i don't know what is the problem? here is my config file which shows the following: (see that if it can help)

<authentication mode="Forms"/>

<authorization>

<allow roles="admin, users, client"/>

<!--when you create a role from the administration tools in the website,

the above code is added to the web config.-->

</authorization>

the first page that load in my application is the login page. this then will allow all these roles the access to the home page (based on their authentication) where all other pages are located.

so when the person click on a page that is not authorized to see it, i would like to redirect the person to a page where it says "access denied you don't have enough previlige".

how can i do this. thank you very much


  #2 (permalink)  
Old March 12th, 2006, 05:52 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Is the error message correct? That is, is there indeed no /ECBS/login.aspx page?

By default, .NET sends you to a page called Login.aspx when you access another page in the site that you cannot access with your current credentials....

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #3 (permalink)  
Old March 13th, 2006, 03:39 PM
Authorized User
 
Join Date: Feb 2006
Location: , , .
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for replying.

i understand what you saying, but after the users login to the system and try to view pages that they don't have permission to see, it redirects them to mention path. the problem is, the system shows the above error instead of taken them back to login with enough previlige.

do you think that the above path should be spelled this way: ~/ECBS/login.aspx and if so from where you edit the path?

thanx very much.

  #4 (permalink)  
Old March 13th, 2006, 04:28 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

It depends on where you have saved Login.aspx.

If ECBS is a folder in your app (e.g. you access the Login page with http://localhost/ECBS) then that's indeed the path you need.

You can configure the URL for the Login page in the web.config file on the <forms> element of the <authentication> node:

<authentication mode="Forms">
  <forms name="YourFormsName" loginUrl="~/ECBS/Login.aspx" />
</authentication>


HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #5 (permalink)  
Old March 19th, 2006, 04:49 AM
Authorized User
 
Join Date: Feb 2006
Location: , , .
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank you very much Imar.

Well theproblem was simply my login page was not as part of the master page. So i said probably that's the case, so i created a login page within the master page and it all went good.

but the problem i still face is the "login view". this control works good when you log out from the website but if you don't close the window and tried to log in again it takes you to the page that you have logged out from. Basically, what i want, is when i log out and want to login again (without closing the browser), the system should take me to the home page.

can you please help?

  #6 (permalink)  
Old March 19th, 2006, 04:29 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
quote:Basically, what i want, is when i log out and want to login again (without closing the browser), the system should take me to the home page.
I am not sure what you mean with this, or what the LoginView has to do with it.

Are you saying that although you explicitly logged out, you still want to consider the user as logged in when they open the homepage again?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #7 (permalink)  
Old March 20th, 2006, 04:20 AM
Authorized User
 
Join Date: Feb 2006
Location: , , .
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i'll explain it with the following seanario:

say i have three pages: login page, home page and a change password page.
both home and change psw pages have a longin status (sorry should be login status not loginview) where you can logout from any of these two pages and therefore taken back to the login page.

when you login using the login page, you are redirected to the Home
page, then say you clicked on the change password page and however you want to logout from that page. the problem is that the system takes you to the login page but with a retunUrl (http://localhost:2513/ECBS/login.asp...ePassword.aspx) that if you log in again, you'll be taken back to the change pssw page.

i hope that explain the problem. what can i do to make the system to login back to the home page whenever someone logout from wherever?

thank you?



  #8 (permalink)  
Old March 20th, 2006, 04:11 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

This is actually a feature, in that it allows a user to return to the page they originally requested after they logged in.

One of the ways to circumvent this, is inside the LoggedIn event of the Login control. In that event, you can determine whether you want to let .NET take care of redirecting (tat is, do nothing), or redirect to any page you want, like the homepage.

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Eraser by Nine Inch Nails (Track 11 from the album: The Downward Spiral) What's This?
  #9 (permalink)  
Old March 21st, 2006, 07:33 PM
Authorized User
 
Join Date: Feb 2006
Location: , , .
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank you very much. i basically have change some propereties in the 'login status'. there is a property called 'logout page url' which i have set to the login page. this means when the user logout from wherever he was in the site, the system logs him out to the log in page, and if he tries to login back it takes him to the home page. and that's what i was looking for.



  #10 (permalink)  
Old March 22nd, 2006, 03:08 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Great. Glad it's working now and thanks for sharing your solution.

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Insert Coin by Hardfloor (Track 1 from the album: All Targets Down) What's This?
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem accessing Request.Form with Master Pages kittu_asa ASP.NET 2.0 Basics 1 February 28th, 2008 09:38 AM
Problem accessing Request.Form with Master Pages niceFEPF ASP.NET 2.0 Basics 7 February 14th, 2008 04:25 PM
Accessing through pages DarkForce ASP.NET 2.0 Professional 3 May 30th, 2007 04:31 AM
Accessing User Roles in MS Access through Java sfali Java Databases 0 September 24th, 2003 08:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.