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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 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 - eFeng.Leung 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.