我似乎無法讓Windows身份驗證在Silverlight業務應用程序中工作。Silverlight業務應用程序Windows身份驗證
我已經作出所需的改變見下文
更改爲Windows身份驗證中的App.xaml
public App()
{
InitializeComponent();
// Create a WebContext and add it to the ApplicationLifetimeObjects
// collection. This will then be available as WebContext.Current.
WebContext webContext = new WebContext();
//webContext.Authentication = new FormsAuthentication();
webContext.Authentication = new WindowsAuthentication();
this.ApplicationLifetimeObjects.Add(webContext);
}
在web.config中更改爲Windows身份驗證
<authentication mode="Windows"/>
<roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider"/>
我把一個斷點在Application_UserLoaded事件但沒有任何反應: -
private void Application_UserLoaded(LoadUserOperation operation)
{
foreach (var r in WebContext.Current.User.Roles)
{
//do something
}
}
任何人都可以提出什麼問題。我根本沒有對該項目做任何其他改變。
您是不是想要使用Active Directory中的組或者您打算自己管理組成員身份? – 2011-06-12 15:33:44
嘗試禁用web.config文件中的匿名用戶。但是當我需要知道用戶名時,我調用了一個返回它的wcf服務方法。 – vorrtex 2011-06-12 19:05:04