Simulate a request from an IE client with a WebClient class?
I am uploading files using the WebClient class in .NET 3.5. I would like to be sure that on the server side, the requested files appear to be loaded using the IE client. What do I need to change exactly?
Do I just need to copy the title information generated by IE into the title property of the WebClient object? Anything else I need to do?
thanks
0
source to share
2 answers
Depending on your needs, simply setting the user agent header is sufficient. Example: http://msdn.microsoft.com/en-us/library/system.net.webclient(VS.80).aspx
+3
source to share
The short answer is yes.
The following code contains complete header information, just run it in a browser and you will make the necessary settings.
<html>
<body>
<script type="text/javascript">
var x = navigator;
document.write("CodeName=" + x.appCodeName);
document.write("<br />");
document.write("MinorVersion=" + x.appMinorVersion);
document.write("<br />");
document.write("Name=" + x.appName);
document.write("<br />");
document.write("Version=" + x.appVersion);
document.write("<br />");
document.write("CookieEnabled=" + x.cookieEnabled);
document.write("<br />");
document.write("CPUClass=" + x.cpuClass);
document.write("<br />");
document.write("OnLine=" + x.onLine);
document.write("<br />");
document.write("Platform=" + x.platform);
document.write("<br />");
document.write("UA=" + x.userAgent);
document.write("<br />");
document.write("BrowserLanguage=" + x.browserLanguage);
document.write("<br />");
document.write("SystemLanguage=" + x.systemLanguage);
document.write("<br />");
document.write("UserLanguage=" + x.userLanguage);
</script>
</body>
</html>
0
source to share