How to deal with common sessions of different Web applications on a website during team development

Source: Internet
Author: User
How to deal with the general session of different Web applications on a website during team development)

Columns

How to deal with common sessions of different Web applications on a website during team development

Guo hongjun

Some time ago, I was troubled by the general session problem of different web projects on the same site. With the help of csdn netizens, I found a solution and some related problems on the Internet.Article. However, the descriptions in these articles are not detailed enough. I will sort out the relevant knowledge so that I can search for them in the future and help people who encounter such problems in the future.

Web applications under different virtual directories on the same siteProgramThe session cannot be shared. The default web project created by vs.net is a virtual directory of a project, and a project uses its own web. config and global. asax file, so that we will encounter problems when developing multiple associated projects of a site (sharing resources through sessions.

It is not difficult to solve this problem. merge these projects into a virtual directory. config and global. asax, although one project can be configured, we recommend that you use a set of configurations for the entire web site, and the Web under different directories. config affects the aspx configuration in different directories. If both the root directory and the web application directory have web. as defined in the config file, sessionstate mode = "inproc" obviously the sessions of the two applications cannot be shared.

Specifically, the following conditions can be met to achieve session sharing for the same site.

1. virtual directory settings for sites that need to share sessions, such:

(Figure 1: Delete the virtual directory of an application. Note that you can click the delete button instead of the Uninstall button to delete the application directory file)

2. Ensure that the entire site has something necessary for Web applications, such as web. config and Global. asax. The settings here are responsible for the whole site. A simple method is to create a web application in the root directory of the site.

3. Delete the Web. config and Global. asax files under the general session site directory to affect the settings of the application. For example, the following box indicates that the settings should be deleted in the web. config file of Lori.

 

<Authentication mode = "Windows"/> <sessionstate mode = "inproc"
Stateconnectionstring = "TCPIP = 127.0.0.1: 42424" sqlconnectionstring = "Data Source = 127.0.0.1;

Trusted_connection = yes "cookieless =" false "timeout =" 20 "/>

 
A general session can be used if the preceding conditions are met.
 
The following is a simple demonstration of using the general sessions of different projects on the vs.net development site during team development:
 
Prerequisites:
 
There are two web applications, writesession, and readsession is on the same site. What we want to demonstrate is to write a session value in the writesession web application, such as session ["AAA"] = "123"; then read and retrieve the session value in readsession.
The above two projects are equivalent to the development projects allocated to two people in large-scale Web development. It can be considered that writesession is used to process user login. After login, the login information is recorded to the session, and other web projects such as listing user information in the readsession of another web project
 
1. include two web projects in the same solution, such as webtest, add two existing web projects to this solution)
 
2. Create a new web project. This project is the WEB Project of the entire site. It does not need to contain several web projects under the site. If you see the following in the solution Browser:

(Figure 2 although the aspx file under readsession writersession is also part of the web project ghj1976.csdn.net, It is not listed in the project, which realizes the functions of multiple projects on a site, later, we can see that all readsession writersessions are removed from the virtual directory .)

3. Remove the virtual directory configuration of readsession and writersession according to the method provided in figure 1.

4. delete some settings in the web. config file of the readsession and writesession web projects and delete the boxes mentioned above. (To reduce the trouble, the simplest way is to directly Delete the Web. config and Global. asax files. In this way, the program will call the two configuration files at the upper level, namely, the two files of the Web application ghj1976.csdn.net)

5. Add a reference to the readsession writesession two web projects in the ghj1976.csdn.net web project. Note: it is a project reference, not other references.

(Figure 3 these three web projects are in the same solution, so that project reference can be implemented)

Figure 2 also shows that the two projects are referenced to the ghj1976.csdn.net project.

6. Generate a solution and run the program. Everything is OK.

To publish this program, you only need to copy the files in the bin directory under the root directory.

Other considerations:

Create a new solution that only contains one web project, such as readsession, and modifyCode, Generate a solution, you will find that the execution is not modified by yourself. Haha, of course it won't be the same. This project is no longer a virtual directory, and the execution file he calls is a file in the bin directory under the root directory, rather than under the bin directory under the solution directory.

In team development, writesession can be considered as a public project that everyone must call. readsession can be considered as a project that everyone is responsible for, so that multiple projects in team development can share a session.

There are a lot of articles on how to develop an online team. I won't repeat them here.

Link:

The post on csdn discussing this issue is as follows:

Http://expert.csdn.net/Expert/topic/1773/1773115.xml

307467 how to: create an ASP. NET application from multiple projects for Team

Http://support.microsoft.com /? Id = 307467

How to share session/Application State Processing SS different ASP. NET web applications

Http://www.asp101.com/articles/jayram/sharestate/default.asp

317786 how to: manage multi-project solutions in Visual Studio. NET

Http://support.microsoft.com /? Id = 317786

Copyright Disclaimer: csdn is the hosting service provider of this blog. If this article involves copyright issues, csdn does not assume relevant responsibilities. Ask the copyright owner to contact the author directly.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.