简体   繁体   English

Silverlight 业务应用 Windows 认证

[英]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.

相关问题 SilverLight应用程序(不是Silverlight业务应用程序)中的Windows身份验证 - Windows authentication in SilverLight Application (not Silverlight Business Application) 在Silverlight应用程序中将Windows集成身份验证与SqlRoleProvider一起使用 - using Windows integrated authentication with SqlRoleProvider in silverlight application 具有Windows身份验证的Silverlight和WCF - Silverlight and WCF with Windows Authentication Flex应用程序中的Windows身份验证 - Windows authentication in Flex application 适用于Windows Embedded 7的Silverlight中的多页应用程序 - Multi-page application in Silverlight for Windows Embedded 7 域上的.NET应用程序中的Windows身份验证 - Windows Authentication in .NET application on domain 使用 Windows 网络身份验证登录应用程序 - Log into application with Windows Network Authentication Windows容器中托管的应用程序的Windows身份验证 - Windows authentication of an application hosted in Windows Container 如何在Windows应用程序中使用Windows身份验证? - How to use Windows Authentication in Windows Application? 在Windows Phone 8 Silverlight应用程序的应用程序栏中包含字体图标 - Include font icons in Application Bar of Windows Phone 8 Silverlight App
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM