因此现在可以用于 Intranet 目的;]
我在客户端使用了 MVC+Silverlight+证书
将 Silverlight 项目添加到 Visual Studio 解决方案:
right-click 在 MVC 应用项目上->Properties
SilverLight Application tab-> Add...:
-检查Copy to configuration specific folder
-取消选中Add a test page...
-检查enable Silverlight debugging
银光:在 .xaml.cs 主页:
public MainPage()
{
InitializeComponent();
LayoutRoot.Drop += new DragEventHandler(drop);//important to add
}
private void drop(object sender, DragEventArgs e)
{
if (e.Data!=null)
{
FileInfo[] files = e.Data.GetData(DataFormats.FileDrop) as FileInfo[];
foreach(var item in files)
{
//fullpath in: item.Fullname property
}
}
}
在 xaml 主页设计中
<Grid x:Name="LayoutRoot" Background="#FFBF6666" AllowDrop="true">
<Button x:Name="button" Content="Button" HorizontalAlignment="Left" Margin="72,38,0,0" VerticalAlignment="Top" Width="75" Click="button_Click"/>
</Grid>
right-click Silverlight Project->Properties
Signing tab-> 勾选Sign the xap file->Create the test certificate
在 MVC 应用中查看设置:
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<div id="silverlightControlHost">
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="1000" height="800">
<param name="source" value="/ClientBin/System.xap" />
<param name="onError" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="5.0.61118.0" />
<param name="autoUpgrade" value="true" />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=5.0.61118.0" style="text-decoration:none">
<img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none" />
</a>
</object>
</div>
</asp:Content>
重建两个项目
部署到生产服务器
在 ...trusted root authorities 的客户端安装创建的证书
现在可以正常使用了;]
我看到有些人在 web.config 中添加了 .xap、.xaml 扩展名,但对我来说没有帮助。