我必须使用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>
答案 0 :(得分:0)
来自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 ();