我正在尝试升级使用Silverlight 2的项目来使用Silverlight 4,但我在initparam设置域时遇到问题。
旧的Silverlight 2项目:
<form id="form1" runat="server" style="height:100%;">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div style="height:100%;">
<asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/EKAKC.xap" MinimumVersion="2.0.31005.0" Width="100%" Height="100%" />
</div>
</form>
来自Default.aspx.cs:Xaml1.InitParameters += "Domain=" + domain;
新的Silverlight 4项目:
<body style="height: 100%; margin: 0;">
<form id="form1" runat="server" style="height: 100%;">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div id="silverlightControlHost">
<object type="application/x-silverlight-2" data="data:application/x-silverlight,"
width="300" height="300">
<param name="source" value="EKAKC.xap"/>
<param name="initParams" value="<%= string.Format("WCFReferenceURL={0}", ConfigurationManager.AppSettings["WCFReferenceURL"])%>" />
</object>
</div>
域名不会在我的新Silverlight 4项目中设置
答案 0 :(得分:1)
可能需要对值进行编码: -
<param name="initParams" value="<%= "WCFReferenceURL=" + Server.HTMLEncode(ConfigurationManager.AppSettings["WCFReferenceURL"])%>" />