Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

C# Webserice using POST

I have a C# Webservice being called from VBScript using an HTTP POST. 

If I pass an '&' embedded in one of my arguments the webservice fails when extracting the arguments.  I can get around this by manually escaping the '&' in VBScript and then translating it back in the webservice.  There are some other characters that also cause problems.

My question is, is this the best way to do this?  Is there an alternate approach that would be better?  I'm afraid that part of the problem is that I just don't understand everything that the WebService is doing internally when it processes requests and parses the argument list.

I can't use HTTP GET because of length (some of my arguments may be very long), and I can't use SOAP because my clients won't have a SOAP component installed.

Monday, December 16, 2002

Take a look at the WebClient.UploadValues method.

Dave Rothgery
Monday, December 16, 2002

I'm sorry; I was looking at things from the wrong direction (a C# application calling a non-.NET web service via POST), not a C# web service being POSTed to.

Dave Rothgery
Monday, December 16, 2002

How are you encoding the post parameters? How are you sending the request? Are you sure the request is a properly formed post?

Chris Tavares
Monday, December 16, 2002

I'm manually building key-value pairs and passing them in the body of the POST.

I've done some more searching on MSDN and have a little better understanding of things now - but I still have some questions.

1) Does ASP.NET parse things differently than ASP?  I'm pretty sure (need to double-check) that I was able to pass '&' with POST to an ASP page with no problem.  ASP.NET, however, requires me to escape then '&' first.

2) What's the best method to encode the special characters on the NON .NET client?  Is there an IE DOM method that will handle it, or do I need to do it manually?

I'm using XMLHTTP to build the client-side HTTP transaction.

Monday, December 16, 2002

When you asked about does ASP.NET parse things differently than ASP, well if the web service is bundled into an XML type file, then having an & is illegal in ASP, and needs to be escaped out to &

I'm guessing that ASP.NET on its own does the conversions to & and then brings it back to a normal & when passing it into functions.

Victor Vuong
Saturday, December 21, 2002

*  Recent Topics

*  Fog Creek Home