views:

1520

answers:

1

Hello, I know with ASP.NET there's a global handler Application_EndRequest handler where I could change the Context.Response.StatusCode, and set it to 200 which is my desire.

Now with asmx Web Services, I'm not really sure where I'd put this logic in. I know I'm definitely not interested in writing an ISAPI Filter, and I'm not really running in the ASP.NET environment so HTTPModule is probably useless to me as well.

Any suggestions. Would running this in WCF provide me a simpler mechanism for setting this on a web service?

+2  A: 

While I can not imagine why you need this :), you can try using the WebService.HttpContext.Response and set the status code there.

Also, I'm not sure, but Global.asax event handlers are executed even with web service requests, so you may be able still to use what you want there.

Sunny
I'm not seeing a Global.asax file in myproject. Is this something I'd manually
taudep
Yes, Add new Global Application class
Sunny
Looks like I was easily able to add Global.asax for a web service. Thanks.
taudep
taudep: there's no need to add "answers" - this is not a forum. Adding an answer is just in case you have found out the solution yourself, and want to put it for other users. You can add additional info in your q.(edit), and delete the answers so they do not "extend" the thread.
Sunny
My service didn't initially inherit from WebService, it implemented an interface that I generated with the wsdl.exe tool. I made the the service inherit from WebService so I could access the context, then added the following code: this.Context.Response.StatusCode = 200, but it didn't seem to change anything. I'm thinking there's something else changing the status code during the request, like when the exception is being thrown.I'm going to try and figure out how to get a global.asax file into this project -- there isn't one currently
taudep
Looks like I was easily able to add Global.asax for a web service
taudep