Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 04, 2013 07:17 PM by muhammadazeemazam
Jan 03, 2013 07:29 PM|LINK
i have a button on a page, so when it is clicked it will check the user and allow him the access to admin page. what i want is if he is not the one how can i redirect the user to error.aspx. When the user is ABC i can go to admin page but when i change the
user to bc in web config it says accesss is denied (thats ok). but i want to redirect it to error.aspx. This webconfig is local to the Admin folder. Admin page is in Admin folder names as default.aspx
Jan 03, 2013 08:16 PM|LINK
Write custom errors block in config and add error condition for http 401 status code.
Jan 03, 2013 08:58 PM|LINK
The error i get is
An error occurred while accessing the resources required to serve this request. The server may not be configured for access to the requested URL.
Error message 401.2.: Unauthorized: Logon failed due to server configuration. Verify that you have permission to view this directory or page based on the credentials you supplied and the authentication methods enabled on the Web server. Contact the
Web server's administrator for additional assistance.
Jan 04, 2013 02:53 AM|LINK
Try this in global.asax
Public Sub Application_AuthorizeRequest(ByVal sender As Object, ByVal e As EventArgs)
If (sender.Request.Path.ToUpper().EndsWith("LOGIN.ASPX") And sender.Request.IsAuthenticated) Then
Jan 04, 2013 06:01 AM|LINK
I think you can do it two ways.
1. Only allow admin to login into your admin folder. If another user logs in, instead of sending him to page and then redirecting him to error , directly redirect him to error page.
2. In the page_Init event check the user, if he is the right one, continue if not redirect him to error page.
NOTE : If error page is not in the same folder try using absolute path instead of relative path. Ex:- If your site abc.com then use http://www.abc.com/errors/errorpage.aspx . if you are on locathost then give path according to that.
Hope it helps you.
Jan 04, 2013 06:14 AM|LINK
<customErrors defaultRedirect="SiteErrorPage.aspx" mode="RemoteOnly">
<error statusCode="403" redirect="RestrictedAccess.aspx" />
<error statusCode="404" redirect="pagenotFound.aspx" />
Jan 04, 2013 07:17 PM|LINK
The Problem is when i set my admin page as a start up page and then when i load it if the local webconfig file contains the user it will display the admin page else it will display error. what i want is if the user is not in local config instead of displaying
error it should navigate to anothe page. there r only 10 users out of many who r given acces to this page and they r specified in local webconfig that is in admin folder of project.