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 ...
随机推荐
- GridView格式化数据DataFormatString
设定BoundField的DataFormatString,通常有以下几种 DataFormatString= "{0:C}" 货币,货币的格式取决于当前Thread中Cultur ...
- cocos2dx 动画 二(iOS)
7.Bezier曲线 需要ccBezierConfig结构体,设置2个控制点和一个结束点 ccBezierConfig bc; bc.controlPoint_1 = Vec2(,); bc.cont ...
- POJ3111 K Best(另类背包+二分+变态精度)
POJ3111 K Best,看讨论区说数据有点变态,精度要求较高,我就直接把循环写成了100次,6100ms过,(试了一下30,40都会wa,50是4000ms) 第一次在POJ上看到下面这种东西还 ...
- Say bye to CMake and Makefile
用了几年的CMake,最近想试着琢磨如何将C++应用的动态链接全部改成静态链接,发现还需要研究CMake的用法,进入CMake的文档, http://www.cmake.org/cmake/help/ ...
- github 推送时can't be established.
http://www.xuebuyuan.com/2095099.html 飞凡@FANZ /e/learngit (master)$ git push origin masterThe authen ...
- CFLAGS/CPPFLAGS/CXXFLAGS in Makefile介绍
先来看一张关于Makefile中的常见预定义变量. CFLAGS 表示用于 C 编译器的选项,CXXFLAGS 表示用于 C++ 编译器的选项.这两个变量实际上涵盖了编译和汇编两个步骤.大多数程序和库 ...
- CSAPP--虚拟存储器
虚拟存储器 虚拟存储器(VM)是对主存的一种抽象概念.是硬件一场,硬件地址翻译,贮存,磁盘文件和内核软件的完美交互.他为每个进程提供了一个大的,一致的和私有的地址空间. 它将贮存堪称一个存储在磁盘上的 ...
- http head
Accept HTTP_ACCEPT Accept-Charset HTTP_ACCEPT-CHARSET Accept-Encoding HTTP_ACCEPT-ENCODING Accept-La ...
- 关于nginx架构探究(2)
nginx 数据结构 1.Hash table nginx 对虚拟主机的管理使用到了HASH数据结构,假设配置文件里有如下的配置. Server{ listen 192.168.0.1 server_ ...
- Effective Java Item2:Consider a builder when faced with many constructor parameters
Item2:Consider a builder when faced with many constructor parameters 当构造方法有多个参数时,可以考虑使用builder方式进行处理 ...