473,327 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

access denied message for failed authorization

I want to send users to an Access Denied page rather than the Login
page when they are authenticated but not authorized to see a specific
page while using Forms based authentication in ASP.Net.

the solution in VB is to check the status code in the
Global_EndRequest method of the Global.asax. However, in c# you have
to add your own method to the EndRequest event rather than using the
standard Application_EndRequest that exists in the global.asax.

Has anyone else seen this bahavior?
Can anyone explain this behavior?
Is this a bug?
Code in the Global.asax:

protected void Application_EndRequest(Object sender, EventArgs e)
{
System.Diagnostics.Debug.WriteLine("Application_En dRequest");
System.Diagnostics.Debug.WriteLine("URL: " +
HttpContext.Current.Request.Url.AbsolutePath.ToStr ing());
System.Diagnostics.Debug.WriteLine("Staus Code: " +
HttpContext.Current.Response.StatusCode);
System.Diagnostics.Debug.WriteLine("Authenticated: " +
HttpContext.Current.User.Identity.IsAuthenticated) ;
}

protected void Global_EndRequest(Object sender, EventArgs e)
{
System.Diagnostics.Debug.WriteLine("Global_EndRequ est");
System.Diagnostics.Debug.WriteLine("URL: " +
HttpContext.Current.Request.Url.AbsolutePath.ToStr ing());
System.Diagnostics.Debug.WriteLine("Staus Code: " +
HttpContext.Current.Response.StatusCode);
System.Diagnostics.Debug.WriteLine("Authenticated: " +
HttpContext.Current.User.Identity.IsAuthenticated) ;
}

#region Web Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.EndRequest += new
System.EventHandler(this.Global_EndRequest);
}
#endregion


Result:

Global_EndRequest
URL: /WebAuthentication/authenticated/Role4Only.aspx
Staus Code: 401
Authenticated: True

Application_EndRequest
URL: /WebAuthentication/authenticated/Role4Only.aspx
Staus Code: 302
Authenticated: True
Nov 17 '05 #1
0 2112

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Robin Chatterjee | last post by:
Hi, I am constantly getting this error inspite of all that i do. Pls help if you can ASAP. My environment is 1. In the Webconfig i have <authentication mode="Windows"/> <identity...
2
by: mal hit | last post by:
We developed an ASP.NET application on Windows 2000/SQL Server 2000/IIS 5.0. Recently, we moved the SQL Server 2000 database to Windows 2003. Now, we are unable to connect to the database (on...
29
by: Patrick | last post by:
I have the following code, which regardless which works fine and logs to the EventViewer regardless of whether <processModel/> section of machine.config is set to username="SYSTEM" or "machine" ...
2
by: Raed Sawalha | last post by:
I am trying to authenticate user against a domain for access to my website. My webserver is a client on the domain. On the local machine policy for the "Users" group. The SAT domain has an entry...
1
by: Jody Gelowitz | last post by:
We are having an issue in that when trying to read a file that is on Server2 from Server1 (through our ASP.NET project), we receive the error: Access to the path "\\Server2\MyShare\MyFile.tif" is...
3
by: Shailesh Humbad | last post by:
I figured out what was causing the "Access is Denied" error when calling functions from referenced DLLs in my service. I've tried to be very detailed, so bear with me. It turns out that...
1
by: Rachel | last post by:
I have created a simple web service in VC# that adds two numbers. It returns an integer value to the client once invoked. I used Visual Studio .NET 2003, Windows XP Pro and .NET 1.1. I created a...
1
by: khalid Ahmed | last post by:
Hi, I'm using ASP.NET custom membership provider, I have created a list of users and their roles in a single XML file. I'm using three login controls in my app, one located at Admin/login.aspx...
1
by: Chase Kang #52 | last post by:
I have a web application using custom authentication and role management, which seems to work properly. I also have a web config file with the following: <location path="systems"> <system.web>...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.