I'm developing a WinForms app that consumes web services. I've added my own httpModule that handles the Application_AuthenticateRequest method. Every time the client application calls a web service the httpModule extracts the credentials embedded in the SOAP
header and performs various checks. However, I find that whenever an exception is thrown (doesn't matter what type) the method does not return a SoapException but rather the html markup for the default ASP.NET error page! This is unacceptable is it contains
a stack trace in the markup.
For example, if I run the client app through the VS debugger and purposely change some of the credential values being sent to the web service I receive this System.Exception:
System.Exception was unhandled by user code
Message="Client found response content type of 'text/html; charset=utf-8', but expected 'text/xml'.\r\nThe request failed with the error message:\r\n--\r\n<html>\r\n <head>\r\n <title>We're sorry but we were unable to validate your credentials.
Please login again. Contact Spring Mill Software if this error continues to persist.</title>\r\n <style>\r\n body {font-family:\"Verdana\";font-weight:normal;font-size: .7em;color:black;} \r\n p {font-family:\"Verdana\";font-weight:normal;color:black;margin-top:
-5px}\r\n b {font-family:\"Verdana\";font-weight:bold;color:black;margin-top: -5px}\r\n H1 { font-family:\"Verdana\";font-weight:normal;font-size:18pt;color:red }\r\n H2 { font-family:\"Verdana\";font-weight:normal;font-size:14pt;color:maroon
}\r\n pre {font-family:\"Lucida Console\";font-size: .9em}\r\n .marker {font-weight: bold; color: black;text-decoration: none;}\r\n .version {color: gray;}\r\n .error {margin-bottom: 10px;}\r\n .expandable { text-decoration:underline;
font-weight:bold; color:navy; cursor:hand; }\r\n </style>
...
and so on and so forth...
Any ideas or suggestions are appreciated.
This application is using .NET 2.0 on a WinXP pro machine
Hey there fellow St. Louisan. This can happen when you use an HTTP GET instead of a POST. HTTP GET has limitations when it comes to a sophisticated web service request. Irregardless, it sounds to me like it's failing before it even gets to your web service
and the HTTP error is not mapped back properly.
None
0 Points
23 Posts
Problem with custom authentication using httpModule
Jun 10, 2006 08:41 PM|DataBound|LINK
I'm developing a WinForms app that consumes web services. I've added my own httpModule that handles the Application_AuthenticateRequest method. Every time the client application calls a web service the httpModule extracts the credentials embedded in the SOAP header and performs various checks. However, I find that whenever an exception is thrown (doesn't matter what type) the method does not return a SoapException but rather the html markup for the default ASP.NET error page! This is unacceptable is it contains a stack trace in the markup.
For example, if I run the client app through the VS debugger and purposely change some of the credential values being sent to the web service I receive this System.Exception:
System.Exception was unhandled by user code
Message="Client found response content type of 'text/html; charset=utf-8', but expected 'text/xml'.\r\nThe request failed with the error message:\r\n--\r\n<html>\r\n <head>\r\n <title>We're sorry but we were unable to validate your credentials. Please login again. Contact Spring Mill Software if this error continues to persist.</title>\r\n <style>\r\n body {font-family:\"Verdana\";font-weight:normal;font-size: .7em;color:black;} \r\n p {font-family:\"Verdana\";font-weight:normal;color:black;margin-top: -5px}\r\n b {font-family:\"Verdana\";font-weight:bold;color:black;margin-top: -5px}\r\n H1 { font-family:\"Verdana\";font-weight:normal;font-size:18pt;color:red }\r\n H2 { font-family:\"Verdana\";font-weight:normal;font-size:14pt;color:maroon }\r\n pre {font-family:\"Lucida Console\";font-size: .9em}\r\n .marker {font-weight: bold; color: black;text-decoration: none;}\r\n .version {color: gray;}\r\n .error {margin-bottom: 10px;}\r\n .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }\r\n </style>
...
and so on and so forth...
Any ideas or suggestions are appreciated.
This application is using .NET 2.0 on a WinXP pro machine
Gary
None
0 Points
23 Posts
Re: Problem with custom authentication using httpModule
Jun 13, 2006 12:50 AM|DataBound|LINK
Is there any way to change this behaviour and send back, say, an exception rather than the markup?
Gary
None
0 Points
14 Posts
Re: Problem with custom authentication using httpModule
Jun 13, 2006 08:50 PM|EmeraldMound|LINK
Hey there fellow St. Louisan. This can happen when you use an HTTP GET instead of a POST. HTTP GET has limitations when it comes to a sophisticated web service request. Irregardless, it sounds to me like it's failing before it even gets to your web service and the HTTP error is not mapped back properly.
Mike
None
0 Points
14 Posts
Re: Problem with custom authentication using httpModule
Jun 13, 2006 08:52 PM|EmeraldMound|LINK
Looking at the error your response is being returned as HTML/UTF-8 not XML. Check your encoding.
Mike