未授权用户如何自动显示登录窗口 [英] How for an unauthorized user automatically show the login window

查看:182
本文介绍了未授权用户如何自动显示登录窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的大师!
$
Silverlight应用程序使用微软的标准授权。当您按下登录按钮时 - 它显示授权表格:



Dear Guru !
In silverlight application uses a standard authorization from microsoft. When you press the Login button  - it shows the authorization form :

private void LoginButton_Click (object sender, RoutedEventArgs e)
        {
            LoginRegistrationWindow loginWindow = new LoginRegistrationWindow ();
            loginWindow.Show ();
        }




我无法理解我必须在哪里插入代码




I can not understand where I have to insert the code

if (WebContext.Current.User.IsAuthenticated)
            {
                LoginRegistrationWindow loginWindow = new LoginRegistrationWindow ();
                loginWindow.Show ();
            }

自动显示的
,如果用户未登录(无需点击"登录")。不能有任何身体帮助?
$

that was displayed automatically, if the user is no logged on (no need to click on the "Login"). Can't any body help?

推荐答案

您好,

如果您使用的是Silverlight应用程序,默认情况下没有像常规Web应用程序那样的会话。因此,应用程序之间没有任何机会失去身份验证。

if you are using Silverlight application, by default there were nothing like sessions unlike usual web application. So there were not any chance in between application looses authentication.

在这种情况下,As Silverlight是客户端应用程序,拥有此代码的最佳位置是应用程序启动。当用户第一次进入系统时。

In this case, As Silverlight is client application, the best place to have this code is application start up. When user first time enter into the system.

因此,这可能在App.xaml中的onStartup()方法内,这是应用程序的应用程序入口点。

So, this may be inside onStartup() method in App.xaml which is application entry point to application.

如果您正在维护会话和身份验证服务,那么我们还可以检查每个请求中的身份验证。为了执行此操作,我们可以在自定义基类中编写上述代码。我们可以拥有自定义基类和从
基类派生的所有页面。它有Initalize()方法,它将在每个写入此代码的请求上执行。

if you are maintaining session and authentication service then we can also check for authentication in each request. To perform this we can write the above code inside the custom base class. We can have custom base class and all the pages derived from that base class. it have Initalize() method which will execute on each request where this code can be written.

希望,这将有助于您理解和选择方向。如有疑问,请随时联系。

Hope, this will help you to understand and choose the direction. Feel free to contact in case of query.


这篇关于未授权用户如何自动显示登录窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆