HTTP Posts

  • Thread starter Thread starter Ben
  • Start date Start date
B

Ben

Hi,
I have several forms that need to post data to a remote site and currently
they just do a POST action with the data. I am trying to centralise the code
which manages the parameters for easier upgrade and maintenance, so i was
thinking of having all the form 'submit' buttons just pass the data to my
class which would take care of forming the Query to be sent across.

Just wondering, to make this call (HTTP POST) should i use some HttpRequest
classes? and will i get error responses (if any) from the remote server that
I can parse?

Any thoughts ?

cheers
ben
 
I think I have it ... I could use the WebClient class ..

But does the approach make sense ? id rather keep the presentation layer
separate from any communications with backend systems and thought this might
be a good way to do it ..

Thanks
 
It's common to do this in this fashion. WHy do you worry about this
approach? The only issue you might have is that this request might be slow
and tying up one of ASP.Net's threads for a period of time.

If you can do without knowing hte result of the remote operation you can
maybe run it on a separate thread and just let it die or use asynchronous
ASP.Net requests. This would only make sense though if there's a performance
problem in the first palce.

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/wwHelp
 
Thanks Rick... I havent tried this kind of abstraction in the past so I was
wondering if its a common thing to do.

actually these forms POST search keywords to a third party sitesearch
service which responds to the query string by generating a HTML page with
the search results. I guess i cant do the asynchronous approach since the
user will push the button and wait for the search results page.

Cheers
Ben
 
Ben,

Unless you have load issues in terms of high traffic load and the requests
take a long time to complete I wouldn't really worry about this. If you do
you can look into Async HTTP requests on the server which will leave you to
process without tieing up ASP.Net's thread process pool.

There was a detailed article in MSDN magazine on this topic a few months:

http://msdn.microsoft.com/msdnmag/issues/03/06/Threading/default.aspx

At the very end of the article it talks exactly about how to implement ASPX
pages that run async by implenting IHttpAsyncHandler in your page (or
creating a custom page class that supports it).

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/wwHelp
 
Back
Top