在asp.net中用户配置文件

编程入门 行业动态 更新时间:2024-10-09 11:22:57
本文介绍了在asp中用户配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

I have an asp 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:

的msdn.microsoft/en-us/library/system.web.profile.sqlprofileprovider.aspx

更多推荐

在asp.net中用户配置文件

本文发布于:2023-11-07 15:34:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1566833.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:配置文件   用户   asp   net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!