如何解决需要在启动时登录Silverlight业务应用程序模板吗?
| 我希望我的Silverlight业务模板应用程序要求用户登录后才能访问任何页面(无匿名用户)。 看来这应该/将是一件简单的事情。 有人吗 谢谢 注意:我是Silverlight和业务模板的新手,如果有一种“正常”方式锁定Silverlight应用程序,例如在.aspx(在web.config中)中使用的话,也要帮忙。 *几乎答案* 我想我回答了我自己的问题。 我在不需要匿名访问的页面上使用此功能。protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (!WebContext.Current.User.IsAuthenticated)
{
LoginRegistrationWindow login = new LoginRegistrationWindow();
login.Show();
Uri uri = new Uri(\"/Home\",UriKind.Relative);
this.NavigationService.Navigate(uri);
}
}
解决方法
我在Mattias Fagerlund的Coding Blog上找到了这个由三部分组成的教程,该教程回答了我所有的问题和一些其他问题
需要登录的Silverlight页面
http://lotsacode.wordpress.com/2010/02/21/silverlight-pages-that-require-login-part-1/
,
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (!WebContext.Current.User.IsAuthenticated)
{
LoginRegistrationWindow login = new LoginRegistrationWindow();
DialogResult dlg= login.Show();
if (dlg.Cancel)
{
Uri uri = new Uri(\"/Home\",UriKind.Relative);
this.NavigationService.Navigate(uri);
}
}
}
好的...使用了错误的语言,但我当时在家,无法访问我的代码...
Views.LoginForm login = new Views.LoginForm();
login.Closed += (s,e2) =>
{
if (login.DialogResult == true)
{
ContentFrame.Content = null;
Views.PrimarySearchView view = new Views.PrimarySearchView();
ContentFrame.Content = view;
Wait.End();
}
else
{
ContentFrame.Content = null;
}
};
login.Show();
这假定LoginRegistrationWindow是ChildWindow
您现在应该可以从我的样本中获得要点。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。