Asp.net中多项目共享Session

1. 建立一个空白解决方案 blank solution ,如: d:\MyProject\MyProject.sln

2. 在 d:\MyProject 下建一个 Web Application 的根目录 d:\MyProject\WebMis 并设为 http://localhost/WebMis 的虚拟目录

3. 在 WebMis 目录下根据模块分别新建目录,如: d:\MyProject\WebMis\Login 和 d:\MyProject\WebMis\CheckOut

4. 在 VS.net 中根据模块新建 web application ,如: http://localhost/WebMis/Login 和 http://localhost/WebMis/CheckOut

5. 新建后 Login 和 CheckOut 两个目录自动被设置为虚拟目录

6. 在 WebMis 项目中添加 Login 和 CheckOut 的项目引用

7.在 IIS 管理器中删除 Login 和 CheckOut 的虚拟目录

8. 删除各项目的 global.asax (除根项目)

9. 除去个项目的 web.config (除根项目)中的如下代码:

1<authentication mode="Windows"></authentication>
1<sessionstate cookieless="false" mode="InProc" sqlconnectionstring="data source=127.0.0.1;Trusted_Connection=yes" stateconnectionstring="tcpip=127.0.0.1:42424" timeout="20"></sessionstate>

或删掉 web.config (若不需要在各目录中进行配置)

10. 编译后,即可运行。

Published At
Categories with Web编程
Tagged with
comments powered by Disqus