473,320 Members | 2,029 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,320 software developers and data experts.

Programmatically turn off custom errors for current request

Hello all,

The app we are working on uses custom errors extensively to provide
friendly error pages to users whilst logging the actual exceptions
behind the scenes.

However.... We are now having to integrate some Web services into the
application using the existing architecture. These Web services are
secured using Forms Authentication. Hence, we need to turn the default
behavior of Forms Authentication (redirects to login pages, etc) into
exceptions that can be handled by a non GUI client (ie. Web service
consumer).

Heres the problem....

In the AuthenticateRequest event, we check if a secure Web service is
being called. If so, we check for an authentication ticket in the Soap
header. If its not there, we throw a "MissingAuthenticationTicket"
custom exception. This gets wrapped in a SoapException and we want
this to get passed to the client.

However.... the custom error page gets called instead, redirecting the
client to Error.aspx and logging the exception on the server. This is
secure, but very hard to handle at the client.

Anyway, what I would like to be able to do is just before throwing the
MissingAuthenticationTicket exception, turn off custom errors for this
request only. Hence the exception would get passed to the client as
expected.

Is there anyway to achieve this?

Thanks in advance for any help,
Regards,
Matt
Nov 18 '05 #1
2 2514
Hi Matt:

Since no one has responded as yet I though I'd through out an idea I
had.

If you handle the Application_Error event in global.asax you might be
able to prevent the redirect with a call to ClearError. I have not
tried this, mind you, just an idea.

If you need to get "state" information from AuthenticateRequest to
Application_Error, you could use the Content.Items collection to hold
some sort of sentinal object.

HTH,

--
Scott
http://www.OdeToCode.com

On 30 Jun 2004 05:36:11 -0700, Ma********@BTInternet.com (Matt) wrote:
Hello all,

The app we are working on uses custom errors extensively to provide
friendly error pages to users whilst logging the actual exceptions
behind the scenes.

However.... We are now having to integrate some Web services into the
application using the existing architecture. These Web services are
secured using Forms Authentication. Hence, we need to turn the default
behavior of Forms Authentication (redirects to login pages, etc) into
exceptions that can be handled by a non GUI client (ie. Web service
consumer).

Heres the problem....

In the AuthenticateRequest event, we check if a secure Web service is
being called. If so, we check for an authentication ticket in the Soap
header. If its not there, we throw a "MissingAuthenticationTicket"
custom exception. This gets wrapped in a SoapException and we want
this to get passed to the client.

However.... the custom error page gets called instead, redirecting the
client to Error.aspx and logging the exception on the server. This is
secure, but very hard to handle at the client.

Anyway, what I would like to be able to do is just before throwing the
MissingAuthenticationTicket exception, turn off custom errors for this
request only. Hence the exception would get passed to the client as
expected.

Is there anyway to achieve this?

Thanks in advance for any help,
Regards,
Matt


Nov 18 '05 #2
Hi Scott,

Thanks for the suggestions. I have tried sticking some code in the
Application OnError handler to prevent the redirect.

What I did was check for a SoapException, and do a Repsonse.End if so.
This prevents the redirect and returns the exception.... However, as in
text/html format!!!

In desperation, I tried something along the lines you say about getting
the error to bubble using the context.items collection.

What I have done is... (and its a BIGGGGG hack!)..
If the authentication ticket is missing:
1) Set SkipAuthentication to true on the current context
2) Add "MissingAuthTicket" to context items collection
3) In the actual secured Web service (!), check for MissingAuthTicket in
the context, and throw the exception if it is!
The point is, the exception gets thrown properly in the Web service
without being redirected by the custom error handler.

Im not proud of this code ;)

Thanks again,
Kind regards,
Matt

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3

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

Similar topics

6
by: Shabam | last post by:
A web application of mine developed using C# + MS SQL runs fine normally. However when I stress test it with a load testing software (using about 60 simultaneous users) some instances start...
3
by: Michael Iantosca | last post by:
I have a custom attribute that I attach to certain pages in my application and I want to inspect each page request as it is made to see if the custom attribute is attached to the underlying page...
6
by: John Lau | last post by:
Hi, I am looking at the MS KB Article 306355: HOW TO: Create Custom Error Reporting Pages in ASP.NET by Using Visual C# .NET This article describes how to redirect errors to a custom html...
1
by: Beren | last post by:
Hello With trial and error I'm attempting to create an extended identity to store some more data than just the Name, for example a Subscription and a LastSearchPerformed property... Is this a...
3
by: Steve Franks | last post by:
Is there a way I can extend the HttpContext or one of its subclasses to include a property that exposes a custom class of mine to all ASP.NET pages? More specifically, I'd like to use a...
3
by: Codex Twin | last post by:
Hello apologies if this is the wrong newsgroup to be sending this to. Basically, I have an ASP.NET application that I am trying to force to use a proxy server settings. This can be done by...
1
by: Joey | last post by:
Hello, I have tried to programmatically set the theme for my master page by putting code in a "Page_PreInit" fuction in the master page's code behind. However, when I set a breakpoint there and...
4
by: =?Utf-8?B?QWxm?= | last post by:
Hello all, I am having trouble dealing with ~(tilde) in my .Net 1.1 web application, specially when it comes through the URL. For example, when someone requests the following URL:...
0
by: Jordan S. | last post by:
Using .NET 3.5... in a "plain old" .aspx page I have the following code in the Init event: this.Context.Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));...
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...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.