1

Is it possible to make an exact identical POST with HttpWebRequest in C# as a browser would? Without a page being able to detect that it is actually no browser?

If so, were could i read up more on that?

user1213488
  • 473
  • 2
  • 7
  • 19
  • UserAgent - http://stackoverflow.com/questions/3057328/httpwebrequest-useragent-what-does-it-do – wkl May 10 '12 at 20:03
  • @seth flowers is correct use Fiddler. You can capture posts and replay them. If nothing else it will give you the information need to duplicate the post. – Chuck Conway May 10 '12 at 20:09
  • No site would be able to detect that? Its always possible with Fiddler and HttpWebRequest? – user1213488 May 10 '12 at 20:11
  • Just trying to understand difference between a browser and HttpWebRequest :) – user1213488 May 10 '12 at 20:11
  • Fiddler will allow you to actually see the actual web-request. You can set some property in HttpWebRequest and see it in action inside fiddler. – A G May 10 '12 at 20:14

2 Answers2

2

Download and become familiar with a tool like Fiddler. It allows you to inspect web requests made from applications, like a normal browser, and see exactly what is being sent. You can then emulate the data being sent with a request created in C#, providing values for headers, cookies, etc.

Seth Flowers
  • 8,990
  • 2
  • 29
  • 42
1

I think this is doable.

Browser detection is done based on a header in the request. All you need to do is set that header. In HttpWebRequest we dont need to set the headers collection but rather the .UserAgent property.

Eg:

.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)";

There is quite a lot to user agents. Check this link for the complete list of User-Agents

Useful Links:

How to create a simple proxy in C#?
Is WebRequest The Right C# Tool For Interacting With Websites?
http://codehelp.smartdev.eu/2009/05/08/improve-webclient-by-adding-useragent-and-cookies-to-your-requests/

Community
  • 1
  • 1
A G
  • 21,087
  • 11
  • 87
  • 112