web.config中的profile
aspnet_regsql命令创建需要的表结构
public class UserProfile:ProfileBase
{
[SettingsAllowAnonymous(true)] //默认匿名用户不能访问
public string MyTest
{
get
{
return (string)base["mytest"];
}
set
{
base["mytest"] = value;
}
} }
<system.web>
<compilation debug="true" targetFramework="4.0" />
<anonymousIdentification enabled="true"/>
<authentication mode="Forms">
<forms loginUrl="a.html"></forms>
</authentication>
<profile defaultProvider="mySqlProfileProvider" inherits="WebApplication1.UserProfile">
<providers>
<clear/>
<add name="mySqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" applicationName="aa.com" connectionStringName="aspnetdb" description="mySqlProfileProvider"/>
</providers>
<properties>
<add name="A" /> <!--默认是string类型,匿名用户能够访问-->
<add name="B" type="System.Int32"/>
<add name="C" allowAnonymous="false" />
<group name="lists">
<add name="a" type="int"/>
</group>
</properties>
</profile>
</system.web>
<connectionStrings>
<add name="aspnetdb" connectionString="Data Source=.;Initial Catalog=aspnetdb;Persist Security Info=True;User ID=sa;Password=123" providerName="System.Data.SqlClient"/>
</connectionStrings>
在properties中添加的name会放到默认生成的对象ProfileCommon中,ProfileCommon默认继承ProfileBase,但是可以自定义Profile,此时ProfileCommon会继承自定义的Profile【如上文中的UserProfile】。Profile中的信息会持久化到指定的数据库中。
web.config中的profile的更多相关文章
- ASP.NET web.config中的连接字符串
在ASP.NET的web.config中,可以用两种方式来写连接字符串的配置. <configuration> <appSettings> <add key=" ...
- 在Asp.Net MVC 中如何用JS访问Web.Config中appSettings的值
应用场景: 很多时候我们要在Web.Config中添加appSettings的键值对来标识一些全局的信息,比如:调用service的domain,跳转其他网站页面的url 等等: 那么此时就涉及到了一 ...
- 【转载】App.config/Web.config 中特殊字符的处理
写一个网站,遇到一个问题,发布以后,提示错误,但是即使打开错误提示(在web.config中打开),还是只提示错误,没提示什么地方错误,这让我知道了:是webconfig本身的错误,经过排除,是链接字 ...
- 因为此控件已在 web.config 中注册并且与该页位于同一个目录中
在web.config文件配置了用户控件 <pages> <controls> <add tagPrefix="my" tagName="l ...
- 使用IConfigurationSectionHandler在web.config中增加自定义配置
一. 场景 这里仅举一个简单应用的例子,我希望在web.config里面增加网站的基本信息,如:网站名称,网站版本号,是否将网站暂时关闭等.二. 基本实现方法1. 定义配置节点对应的类:Site ...
- web.config中配置页面出错后跳转指定错误页面
每当用户访问错误页面时,会出现不友好的404错误,所以为了防止这种不友好,我们在web.config中的<system.web>节点下配置 <customErrors>,在出现 ...
- (译)利用ASP.NET加密和解密Web.config中连接字符串
介绍 这篇文章我将介绍如何利用ASP.NET来加密和解密Web.config中连接字符串 背景描述 在以前的博客中,我写了许多关于介绍 Asp.net, Gridview, SQL Server, A ...
- ASP.Net Web.config 中引用外部config文件
1. 前提准备: Web.config file: <?xml version="1.0" encoding="utf-8"?><config ...
- 利用ASP.NET加密和解密Web.config中连接字符串
摘自:博客园 介绍 这篇文章我将介绍如何利用ASP.NET来加密和解密Web.config中连接字符串 背景描述 在以前的博客中,我写了许多关于介绍 Asp.net, Gridview, SQL Se ...
随机推荐
- (转)C# DateTime格式化大全
//c datetime 格式化 DateTime dt = DateTime.Now; Label1.Text = dt.ToString();//2005-11-5 13:21:25 Label2 ...
- iOS在UITableViewController里使用UISearchDisplayController报错"[UISearchResultsTableView dequeueReusableCellWithIdentifier:forIndexPath:]"
出现如下错误: 2016-02-13 22:09:22.318 Test[2757:192106] *** Assertion failure in -[UISearchResultsTableVie ...
- C#--比较
类型比较: 在比较对象时,常常需要知道它们的类型,这样才能确定是否可以进行值的比较. 方法一. 可以将GetType()方法和typeof()运算符一起使用,就可以确定对象的类型. 例子: int i ...
- 神经网络作业: NN LEARNING Coursera Machine Learning(Andrew Ng) WEEK 5
在WEEK 5中,作业要求完成通过神经网络(NN)实现多分类的逻辑回归(MULTI-CLASS LOGISTIC REGRESSION)的监督学习(SUOERVISED LEARNING)来识别阿拉伯 ...
- [Leetcode][019] Remove Nth Node From End of List (Java)
题目在这里: https://leetcode.com/problems/remove-nth-node-from-end-of-list/ [标签] Linked List; Two Pointer ...
- Javascript中的var_dump函数
最近在做基于OpenSocial的应用,在调试JavaScript时候有一个很头大的问题,就是没有类似PHP的var_dump()的函数,可以把变数内的资料印出来看看, debug时就只能不断的doc ...
- div弹出登录窗口
<meta charset="utf-8"/> <script type="text/javascript"> //弹出式登录 func ...
- 参数解析argparse模块
argparse,python的一个命令行解析模块 import argparse #创建一个命令行解析器 parser = argparse.ArgumentParser() #增添参数 parse ...
- Hdu1097(计算a的b次幂最后一位数值)
#include <stdio.h> #include <math.h> int main() { int Num1,Num2; while(scanf("%d %d ...
- android 中View, Window, Activity, WindowManager,ViewRoot几者之间的关系
(1)View:最基本的UI组件,表示屏幕上的一个矩形区域. (2)Window: 表示一个窗口,不一定有屏幕那么大,可以很大也可以很小: 它包含一个V ...