0

我正在使用 .NET 3.5 中的 WebClient 类下载文件。我想确保在服务器端,请求的文件似乎是通过 IE 客户端下载的。我到底要改变什么?

我是否只需将 IE 生成的标头信息复制到 WebClient 对象的 Header 属性中?还有什么我需要做的吗?

谢谢

4

2 回答 2

3

根据您的需要,只需设置用户代理标头就足够了。http://msdn.microsoft.com/en-us/library/system.net.webclient(VS.80).aspx有一个例子

于 2009-05-04T23:49:32.240 回答
0

简短的回答是肯定的。

以下代码提供了完整的标头信息,只需在您想要的浏览器中运行它即可完成您应该完成的设置。

<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>
于 2009-05-04T23:52:11.907 回答