惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
人人都是产品经理
人人都是产品经理
S
Securelist
P
Proofpoint News Feed
H
Help Net Security
S
Schneier on Security
T
Tenable Blog
C
Cisco Blogs
S
Security @ Cisco Blogs
博客园 - 司徒正美
博客园 - 叶小钗
Cisco Talos Blog
Cisco Talos Blog
Google DeepMind News
Google DeepMind News
C
Cybersecurity and Infrastructure Security Agency CISA
Google Online Security Blog
Google Online Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Hacker News: Ask HN
Hacker News: Ask HN
NISL@THU
NISL@THU
云风的 BLOG
云风的 BLOG
V
Vulnerabilities – Threatpost
T
The Blog of Author Tim Ferriss
aimingoo的专栏
aimingoo的专栏
W
WeLiveSecurity
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Jina AI
Jina AI
腾讯CDC
WordPress大学
WordPress大学
Simon Willison's Weblog
Simon Willison's Weblog
Vercel News
Vercel News
小众软件
小众软件
N
Netflix TechBlog - Medium
有赞技术团队
有赞技术团队
AWS News Blog
AWS News Blog
雷峰网
雷峰网
Forbes - Security
Forbes - Security
The Hacker News
The Hacker News
博客园 - 聂微东
F
Full Disclosure
量子位
Scott Helme
Scott Helme
宝玉的分享
宝玉的分享
A
About on SuperTechFans
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Schneier on Security
Schneier on Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
K
Kaspersky official blog
AI
AI
SecWiki News
SecWiki News
Webroot Blog
Webroot Blog
Martin Fowler
Martin Fowler

博客园 - eFeng.Leung

枚举Exchange Server、SotreGroups和MailStore Single Sign-On for everyone 关于AD编程的一些资料 zz Code Project中几篇关于DNN的文章 Authenticate a user against the Active Directory using the user ID and password User Object User Interface Mapping Lists all entries in the Active Directory Using Active Directory Active Directory and .NET LDAP, IIS and WinNT Directory Services 无法破解的软件注册码算法 SQL2K集群 绑定在 TCP 端口 1433 上失败 使用HTTP访问2003表单登录页 (转) FYI: Getting Started with WebDAV 遭遇 对路径“C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\aa\……”的访问被拒绝 - eFeng.Leung 网络负载平衡部署 Group Panel 在DataGrid里显示Excel文件数据 鼠标移动,改变datagrid里行的色
不同的asp.net web应用程序间共享Session/Application - eFeng.Leung - 博客园
eFeng.Leung · 2006-05-17 · via 博客园 - eFeng.Leung


整合不同的ASP.NET Web 应用程序
1、打开IIS,删除各个模块项目的由VS.NET建立的虚拟目录
2、新建一个ASP.NET Web 应用程序,比如(MasterWeb)
3、把各个模块拷到MasterWeb目录下
4、打开各个模块的"<ModuleProjectName>.csproj.webinfo" 文件
5、修改.csproj.webinfo 里的URL路径为:
<Web URLPath =
http://localhost/MasterWeb/<ModuleProjectName>/<ModuleProjectName>.csproj" />
6、保留各个模块Web.Confg里对自己模块特殊的部分,保留<appSettings>部分,共性部分移除到MasterWeb的Web.Confg里去
7、删除各个模块的Global.asax* 文件
8、各个模块重新生成,并且确保各个模块输出文件储存到路径<MasterWeb>/bin目录下(各个模块项目-属性-配置属性-生成-输出路径)

This article gives the details of how to share single Application/Session state across different ASP.NET web application projects developed. This is required for web applications developed separately for the sake of modularity and require integration into a single website at a later stage.

It is better to develop each module independent of other. If there is information that needs to be shared across modules, it can be achieved through database and/or Session/Application variables, depending on the requirements. With Visual Studio, each new ASP.NET web application project creates a new virtual directory. This means creating separate Session/Application state for each module/application. Drawback of this approach is there is no way to share same Session/Application across these different modules developed for same website.

Well, it is not a drawback if each module is truly a web application by itself and not part of single website or does not share any thing in common. But what happens when it comes to simple things like login? Mostly applications developed for single website are required to support Single Sign on (SSO) or Share/check some Session/Application variables.

Most of the cases, each module is created as web application, just to allow multiple teams to develop different functionality in parallel, and when it comes to deployment, each module is expected to be part of one single application. Sharing single login session across different modules without much programming effort is the goal of this article.

To allow isolated development of each module and integrate all the modules into single web site, you can do the following:

Develop modules independently:

Create each module as new ASP.NET web application (Using Visual Studio). It is possible that each module might be developed in different location or by different team. Having independent standalone projects make testing of each module easy.

At this point in development phase, each module will have its own virtual directory and it is fine. Focus at this point is developing and testing the functionality of module itself. But things will change at the time of integration and deployment.

Integrating different ASP.NET web applications:

When it is time to Integrate different modules into single application:

  1. Using Administrative Tools -> Internet Services Manager: Delete all virtual directories previously created for each module by Visual Studio .net.
  2. Create new ASP.NET Web application (Ex: MasterWeb) project.
  3. Open explorer and copy each module project directory, below MasterWeb project directory.
  4. In each module project directory, open "<ModuleProjectName>.csproj.webinfo" file
  5. Modify URLPath value in .csproj.webinfo file to:

    <Web URLPath = http://localhost/MasterWeb/<ModuleProjectName>/<ModuleProjectName>.csproj" />

    Why? Since there is no virtual directory created for each module, module project file should have right URL so that Visual Studio can open and compile the project.

  6. Open Web.Config file and remove all sections except <appSettings> section (You can move required sections to parent directory Web.Config file). Web.Config in Parent directory of this project will have the common settings required for all modules. Any module specific settings can be overridden in Web.Config file in module project directory (Ex: <appSettings>/connectionString value in may be different for each module).
  7. Make sure that each module .csproj.webinfo file has changes in Step 5.
  8. Make sure that Web.Config file in parent directory (MasterWeb) has all the correct settings required for all modules.
  9. Make sure that each module has Web.Config file with module specific settings in <appSettings> section. If module does not require module specific data, it can share common configuration from parent application (MasterWeb).
  10. Delete any Global.asax* files from each module.
  11. Rebuild all modules and make sure that all module project output assembly files are stored under <MasterWeb>/bin directory (Ref: Step 2).

Integration Testing:

Run the main MasterWeb application and from http://MachineName/MasterWeb and access each module by http://MachineName/MasterWeb/Module1/ module specific directories.

NOTE: All above changes should allow having single Session/Application across different modules. This will allow development of each module separately and integrating them at a later stage. Once deployed, this approach takes less memory as same Session/Application state is used across all modules. Solution described takes: "SAME BUT DIFFERENT" approach during development phase and "DIFFERENT BUT SAME" approach during integration/deployment phase.

Debugging the website:

Open MasterWeb application project in Visual Studio and add all the module projects from sub-directories (Add->Existing Projects). Save this into single solution on Visual Studio. You can compile/debug individual projects or all of them as you prefer.

Assumptions:

It assumed in this article that, most of the .NET/ASP.NET development is done using Microsoft Visual Studio.NET (IDE) and readers are familiar with Visual Studio.NET/ASP.NET.

Placeholders in the document:

"<", ">" brackets in the document represent that actual name should be replaced in place of the string enclosed with "<>". Example: "<MachineName>" should be replaced with actual machine name like "localhost" etc.