在asp.net中用户配置文件 [英] User profiles in asp.net

查看:135
本文介绍了在asp.net中用户配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个asp.net项目,我试图发展用户配置文件的一部分,使用户可以用自己的个人资料(包含管理配置文件和用户)登录。

I have an asp.net project and I am trying to develop the user profile part, so that users can log in with their own profile (profile containing admin and users).

什么情况下可以设置用户计算机上的cookie,当用户登录,然后让网站用户浏览?
我的意思后,经过我检查用户名和密码,通过在每个页面上查看该cookie我让用户浏览网页或重定向到登录页面。

Is it okay to set a cookie on users computer, when the user is logged in and then let the user browse in site? I mean after after I check user name and password, by checking this cookie on every page I let the user browse the page or redirect to the login page.

是这样好吗?

这是安全使用?

有没有更好的办法了吗?

Is this way okay?
Is this safe to use?
Is there any better approach for this?

推荐答案

您可以使用的SqlProfileProvider。添加配置文件属性可以通过添加一些code到您的web.confing完成(部分System.Web程序里面,数据库sqlprofile结构必须是present):

You can use SqlProfileProvider. Adding profile properties can be done by adding some code to your web.confing (inside system.web section, database for sqlprofile structure must be present):

<profile defaultProvider="SqlProvider">
  <providers>
    <clear/>
    <add name="SqlProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ASPNETDB" applicationName="MyApplication" description="SqlProfileProvider"/>
  </providers>
  <properties>
    <add name="LanguageId" allowAnonymous="false" type="System.Int32"/>
    <add name="Company" allowAnonymous="false" type="System.String"/>
  </properties>
</profile>

在这个例子中我已经添加了两个配置文件属性languageId NAD公司。
您可以通过以下code访问此属性:

In this example I have added two profile properties languageId nad Company. You can access this properties using following code:

ProfileBase profile = ProfileBase.Create("SomeUserName");
string company = (string)profile["Company"];

有关的SqlProfileProvider访问以下链接附加信息:

For additional info about SqlProfileProvider visit following link:

http://msdn.microsoft.com/en-us/library/system.web.profile.sqlprofileprovider.aspx

这篇关于在asp.net中用户配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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