[英]Silverlight Business Application Windows Authentication
I cannot seem to get Windows Authentication to work in the Silverlight Business Application.我似乎无法让 Windows 身份验证在 Silverlight 业务应用程序中工作。
I have made the changes required see below我已经进行了所需的更改,请参见下文
Changed to Windows authentication in App.xaml在 App.xaml 中更改为 Windows 认证
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);
}
Changed to Windows authentication in web.config在 web.config 中更改为 Windows 身份验证
<authentication mode="Windows"/>
<roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider"/>
I put a breakpoint on the Application_UserLoaded event but nothing happens:-我在 Application_UserLoaded 事件上设置了一个断点,但没有任何反应:-
private void Application_UserLoaded(LoadUserOperation operation)
{
foreach (var r in WebContext.Current.User.Roles)
{
//do something
}
}
Can anyone suggest what is going wrong.任何人都可以建议出了什么问题。 I have made no other changes to the project at all.
我根本没有对项目进行任何其他更改。
You must have this line in the Application_Startup
:您必须在
Application_Startup
中有这一行:
WebContext.Current.Authentication.LoadUser(this.Application_UserLoaded, null);
This will automatically authenticate a user when using Windows authentication.这将在使用 Windows 身份验证时自动对用户进行身份验证。
This happened to me previously as well.这以前也发生在我身上。 It turned out that Silverlight debugging wasn't enabled in the properties of the Web project.
原来Web项目的属性中没有启用Silverlight调试。 Right click on the.Web project and click on properties.
右键单击.Web 项目并单击属性。 Next click on the Web tab and on the bottom ensure the Silverlight checkbox is checked.
接下来单击 Web 选项卡并在底部确保选中 Silverlight 复选框。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.