path urls relative to root of web app
-
I have a web app with some restricted aspx pages and my security check is being done by the master page of the aspx pages. (not sure if this is a great idea). my problem is if there is no logged in user or he does have the required rights, i forward to a No-Rights error page. I want to specify this page relative from web-app root. This is important to have portable code (locally pages are at localhost/Project-Name/Restricted/etc..., while on server they are at host/Restricted/etc...) Someone suggested the ~ option, but this does not work in code behind - it only works in aspx pages. My security checks, of course, are done in the code behind. any help?
-
I have a web app with some restricted aspx pages and my security check is being done by the master page of the aspx pages. (not sure if this is a great idea). my problem is if there is no logged in user or he does have the required rights, i forward to a No-Rights error page. I want to specify this page relative from web-app root. This is important to have portable code (locally pages are at localhost/Project-Name/Restricted/etc..., while on server they are at host/Restricted/etc...) Someone suggested the ~ option, but this does not work in code behind - it only works in aspx pages. My security checks, of course, are done in the code behind. any help?
I think role based security is what you are looking? If so this article might help http://www.codeproject.com/KB/web-security/formsroleauth.aspx
Coding C# www.excitetemplate.com
-
I have a web app with some restricted aspx pages and my security check is being done by the master page of the aspx pages. (not sure if this is a great idea). my problem is if there is no logged in user or he does have the required rights, i forward to a No-Rights error page. I want to specify this page relative from web-app root. This is important to have portable code (locally pages are at localhost/Project-Name/Restricted/etc..., while on server they are at host/Restricted/etc...) Someone suggested the ~ option, but this does not work in code behind - it only works in aspx pages. My security checks, of course, are done in the code behind. any help?
For the full path use
Page.ResolveUrl()
, for a relative path (relative to the user's browser) usePage.ResolveClientUrl
. Both will take in the ~ format and map it to a real path. If you are in a control, the methods are available from Control as well (Page is a type of Control).Jeremy Likness Latest Article: Whats in Your Collection? Part 1 of 3: Interfaces Blog: C#er : IMage