[英]Change UserAgent programmatically from IE11 to IE 9
我必須使用Crystal Report Viewer打開報表,在IE11上打開時遇到了設計問題,但是將用戶代理更改為IE9會調整報表的設計。 知道我不想更改整個網站的web.config,可以采取什么解決方案來更改頁面的用戶代理字符串。 我需要幫助這是我的代碼:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="rpt.aspx.cs" Inherits="Reports_rpt" %>
<%@ Register Assembly="CrystalDecisions.Web" Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Report</title>
<meta http-equiv="X-UA-Compatible" content="IE=9" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />
<script type="text/javascript">
if (version = /MSIE (\d+\.\d+)/.exec(navigator.userAgent)) {
isIE = true;
browserVersion = parseFloat(version[1]);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div style="width: 800px; height: 700px; margin-left: auto; margin-right: auto;">
<CR:CrystalReportViewer ID="rpt" runat="server" AutoDataBind="True" DisplayGroupTree="False"
ToolPanelView="None" ToolbarImagesFolderUrl="~/aspnet_client/system_web/4_0_30319/CrystalReportWebFormViewer4/Images/ToolBar/" />
<center>
<asp:Label ID="lblMsg" runat="server" Style="display: block; color: orange; font-size: 15pt;" />
</center>
</div>
</form>
</body>
</html>
在Micorsoft的網站上:
WebClient client = new WebClient ();
// Add a user agent header in case the
// requested URI contains a query.
client.Headers.Add ("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
Stream data = client.OpenRead (MyHTMLFile.html);
StreamReader reader = new StreamReader (data);
string s = reader.ReadToEnd ();
Console.WriteLine (s);
data.Close ();
reader.Close ();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.