进程外session

A  SqlServer

1.管理员身份运行cmd

2.更换目录  cd c:\Windows\Microsoft.NET\Framework\v4.0.30319>

3.aspnet_regsql.exe -ssadd -sstype p -S 127.0.0.1 -U sa -P 12345

4.web.config -system.web下添加节点

<sessionState mode="SQLServer" timeout="100" sqlConnectionString="server=.;uid=sa;password=12345;">

</sessionState>

B StateServer

使用aspnet_state.exe

1.开启服务:我的电脑-管理-服务与应用程序-服务-ASP.NET State Service(ASP.NET 状态服务)

2.修改配置文件:
<system.web>节点中添加<sessionState mode="StateServer" stateConnectionString="tcpip=localhost:42424"/>【ASP.NET 状态服务端口号默认:42424】

3.ASP.NET 状态服务只限本机使用如果需要保存外部的Session需要修改注册表

设置是否允许远程使用,位置:C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRenoteConnection值改为 1

测试代码如下:

using System;
namespace WebForm {
    public partial class OutSession : System.Web.UI. Page {
        protected void Page_Load( object sender, EventArgs e) {
            if (Session["key" ] != null) {
                Person p = (Person )Session[ "key"];
                Response.Write(p.GetName());
            } else {
                Session[ "key" ] = new Person( "piziyimao" );
            }
        }
    }
    [ Serializable] //必须是可序列化的类
    public class Person {
        public Person(string n) {
            name = n;
        }
        private string name;
        public string GetName() {
            return name;
        }
    }
}

Web.Config

<? xml version =" 1.0 "?>
< configuration>
       < system.web >
              < compilation debug = "true " targetFramework = "4.0 " />
        < sessionState mode = "StateServer "
                      stateConnectionString =" tcpip=localhost:42424 "/>
       </ system.web >
       < connectionStrings >
              < add name = "ConnStr " connectionString =" server=.;database=School;uid=sa;pwd=123456 " />
       </ connectionStrings >
</ configuration>

参考文件http://blog.csdn.net/dyllove98/article/details/8698397

进程外session的更多相关文章

  1. 探索ASP.NET MVC5系列之~~~6.Session篇(进程外Session)

    其实任何资料里面的任何知识点都无所谓,都是不重要的,重要的是学习方法,自行摸索的过程(不妥之处欢迎指正) 汇总:http://www.cnblogs.com/dunitian/p/4822808.ht ...

  2. Cookie和Session(session过程和设置进程外session)

    cookie 和  session 的区别 cookie 是保存在客户端上的一种机制   而session 是保存在服务端的一种机制 cookie的理解: 打个简单的比方,一个人生病了去A医院看病,回 ...

  3. Asp.Net进程外Session(状态服务器Session、数据库Session)

    介绍 我们知道,当浏览器关闭,或者网站重启的时候,会话就结束了.即Seesion就丢失了.(当Web.config配置文件改动,哪怕什么内容都不加,仅仅往配置文件中加一个空格都是改we.config变 ...

  4. 第四节:框架前期准备篇之进程外Session的两种配置方式

    一. 基本介绍 1. 背景:Asp.Net默认的Session机制是进程内,存储在服务器端内存中,有这么几个缺点: ①:既然存在内存中,空间有限,不能存储大数据量信息,数据量多的话Session会被挤 ...

  5. 配置进程外Session

    配置进程外Session: (1)将服务器Session信息存储在进程外           <1> 首先,开启asp.net state 服务: 控制面板 -> 程序和功能 -&g ...

  6. 学习笔记16_页面缓存/进程外Session

    *页面缓存:适用于访问量较高的网站 <%@OutputCache Duration="15"//缓存15秒  VaryByParam='*' //请求的任何一处发生改变,缓存 ...

  7. 第十六节:Asp.Net Core中Session的使用、扩展、进程外Session

    一. 简介 关于Session的原理可参照Asp.Net版本Session的文章,去查阅. 1. 普通用法 (1).通过Nuget引入[Microsoft.AspNetCore.Http]程序集,Co ...

  8. 配置进程外Session 同时解决一个奇怪的BUG 因为SQLserver 服务器名不是默认的.或者localhost而引发的一系列问题

    用公司的电脑学习如鹏网的视频,开发一个项目,用到了进程外session,因为公司电脑SQLServer 是2008 服务器名称是.  然后参考这篇文章进行设置进程外session 很顺利 完成了设置. ...

  9. .net学习之进程外Session的配置

    转载地址:http://www.cnblogs.com/rohelm/archive/2012/05/13/2498465.html 人人都知道怎么去使用session,但是初学者,尤其是自学的学生可 ...

随机推荐

  1. linux namespace note

    --------------------------------- from http://oldwiki.linux-vserver.org/Namespaces //开源不只是代码,还有思想 Na ...

  2. Java基础之写文件——从多个缓冲区写(GatheringWrite)

    控制台程序,使用单个写操作将数据从多个缓冲区按顺序传输到文件,这称为集中写(GatheringWrite)操作.这个功能的优势是能够避免在将信息写入到文件中之前将信息复制到单个缓冲区中.从每个缓冲区写 ...

  3. decimal类型保留两位小数

    oj.PriceTop =Math.Round(Convert.ToDecimal(reader["PriceTop"]),2);

  4. Eclipse Ctrl+Tab Alt+/ 快捷键

    原来Eclipse的Next Editor 快捷键是 Ctrl+Tab 但是后几个版本将这个快捷键改为Ctrl+F6 了 在Keys设置下面 搜索 NextEditor 将其设置回来即可 同样 原来C ...

  5. 资源Createwindow,对应标识符,绑定窗口

    问? 定义一个CEdit cedit1:怎么和IDC_EDIT1 关联,可以在CEdit.Create()里传进去或者在DoDataExchange()里面绑定,是不是一定要先弄出个IDC_EDIT1 ...

  6. [transferred] javascript exception handling.

    my error handling clause: window.onerror = function (errorMessage, scriptURI, lineNumber, columnNumb ...

  7. zjuoj 3603 Draw Something Cheat

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3603 Draw Something Cheat Time Limit: 2 ...

  8. C++: getline函数

    转自http://blog.sina.com.cn/s/blog_60263c1c0101ck25.html 学习C++的同学可能都会遇到一个getline()函数,譬如在C++premer中,标准s ...

  9. C++之路进阶——codevs2366(朋友圈)

    2366 朋友圈 2012年省队选拔赛河北  时间限制: 10 s  空间限制: 256000 KB  题目等级 : 大师 Master     题目描述 Description 在很久很久以前,曾经 ...

  10. const对象

    const对象不能引用类的非const成员函数