user1373121
user1373121

Reputation: 1039

HttpRequest vs HttpWebRequest

I have a web page that intercepts POST requests, pulls the username out of the request, and is supposed to forward the request on depending on the username. Now, I notice that the incoming HttpRequest has a Params property, and HttpWebRequest does not. Why is this? Is there a way I can capture the Params data in my outgoing HttpWebRequest?

Thanks.

Upvotes: 3

Views: 5082

Answers (2)

paulsm4
paulsm4

Reputation: 121649

They're simply two different .Net classes in two different packages:

   System.Object
      System.MarshalByRefObject
         System.Net.WebRequest
            System.Net.HttpWebRequest
   System.Object
      System.Web.HttpRequest

HttpWebRequest is an old .Net 1.1 thing - I would definitely use Web.HttpRequest if you're planning on refactoring any code (or writing any new code!)

IMHO...

Upvotes: 4

bhamlin
bhamlin

Reputation: 5187

For starters, they're completely different classes, in different namespaces. That being said,

Params is a wrapper that exposes both querystring parameters as well as POST data. When you are construcing a request you can't write to params, you have to specify what kind of data you are actually adding. So you should add it to the target url as a querystring or you can add it to the body of the request and make it a POST.

Upvotes: 1

Related Questions