[Turn]asp.net WebForm share session with MVC

Source: Internet
Author: User

The company's internal system was first developed using the. NET WebForm model, and now the problem with. NET MVC is how to keep the login state of the original. NET WebForm intact, and in MVC it is possible to verify the user's login state, that is, the. NET WebForm The login state saved in the session is shared with MVC.

In the Cnblogs search related data, the basic solution is to save the session state in the database, and then the original program and the new program all get the session state in the database, so as to realize the user login state information sharing.

The specific implementation steps are as follows:

1. Create a database saved by session

Aspnet_regsql-s DB Instance name-ssadd-sstype p-u connection user name

For more information, refer to: http://kb.cnblogs.com/page/71816/

Databases and tables, stored procedures, and so on, as the database creates the corresponding session state

2. Locate the tempgetappid stored procedure in the ASPState database set the application name to unique

2.1. From what we can see, when Webfrom and MVC first access the database, the @aapname provided are different, precisely because of this, the application can only access the respective session state. So you only need to add

The only appid you can get is the unique @appName settings.

1) MVC gets appid in the database

2) WebForm get AppID in the database

3) Locate the Tempgetappid stored procedure in the ASPState database and set the unique appname.

3, set the webconfig of WebForm and MVC, configure the database information of session storage in <system.web> node

<sessionstate mode= "SQL Server" allowcustomsqldatabase= "true" sqlconnectionstring= "Data source=.;i Nitial catalog=aspstate;uid=sa;pwd=abc123 "></sessionState>

4. Setup complete, test effect

[Turn]asp.net WebForm share session with MVC

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.