自定义登录控件。 [英] Custom login control.

查看:77
本文介绍了自定义登录控件。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我想准备登录控件,而不是使用ASP.NET内置的登录视图。我需要你的想法来准备这个。



想法1:这个方法我知道并且工作正常,从用户获取用户名和密码并在数据库中激活选择查询,如果数据库给出记录然后用户被认证,用户名存储在会话变量中。如果我尝试直接使用URL获取其他页面,那么首先我检查会话变量。如果它不是null,那么我们加载页面,否则我们将用户重定向到登录页面。



现在为此我需要在加载前检查每一页,我认为还有一些其他方式,但我无法得到它。



伙计们,请提供您宝贵的建议而不是源代码。代码我将管理。



提前致谢。

Hi guys,

I want to prepared Login control, not use ASP.NET inbuilt Login view. I need your ideas to prepare this.

Idea 1: this method I know and work on fine, get username and password from user and fire select query in database, if database give record then user is authenticated and, user name store in session variable. If I try getting other page directly with URL then first I check the session variable. If it is not null then we load page, otherwise we redirect user to login page.

Now for this I need to check each and every page before loading and I think there some other way also but which I can’t get that.

Guys, please provide me your valuable suggestions not source code. Code I will manage.

Thanks in advance.

推荐答案

这是一篇适合你的文章

http://msdn.microsoft.com/en-us/library/aa478962 .aspx [ ^ ]





希望有所帮助。祝你好运。
Here is an article just for you
http://msdn.microsoft.com/en-us/library/aa478962.aspx[^]


Hope that helps. Good luck.


ASP.NET身份验证和授权 [ ^ ]



授权MSDN [ ^ ]

MSDN表单身份验证 [ ^ ]

其中最好的一个是: -

无Cookie的ASP.NET表单身份验证 [ ^ ]

这些是提供授权的几个非常好的链接每页。

如果您使用的是MVC,您可以使用授权属性制作自定义属性。那肯定会有用。



希望这些对你有帮助。

谢谢。
ASP.NET authentication and authorization[^]

Authorization MSDN[^]
MSDN Forms Authentication[^]
One of the best ones is:-
Cookieless ASP.NET forms authentication[^]
These are few very good links for providing authorization to everypage.
If you are using MVC, you can take use of the Authorization Attribute making a custom one. That would surely work out.

Hope these helps you anyway.
Thanks.


First我建议使用会员资格或身份,因为你将获得所有这些开箱即用。但如果这是用于学习,则将global.asax文件添加到解决方案并使用BeginRequest事件检查用户是否已登录



First off I'd suggest using Membership or Identity as you'll get all this out of the box. But if this is for learning then add a global.asax file to the solution and use the BeginRequest event to check if the user has logged in

<%@ Application Language="C#" %>

<script runat="server">
void Application_BeginRequest(object sender, EventArgs e)
{
   if (string.IsNullOrWhiteSpace(Session["Username"])
   { 
       Response.Redirect("/Login.aspx")
   }

}
</script>


这篇关于自定义登录控件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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