Session value sharing between JSP and ASP. Net

Source: Internet
Author: User

Introduction: after logging on to ASP. NET, JSP can use the Session value in ASP. Net.
At the beginning of this topic, the idea of the baby (itbaby.jss.cn) is to serialize the Session in ASP. NET to save binary data to the database, and then the JSP reads the binary data from the database and deserializes it into a Session pair.
And then forcibly converted to a JAVA Session object. When the JAVA side is switched, an error occurs, and the online data retrieval fails to solve the problem. Therefore, a replacement method is used.
Ideas for the replacement method:
Log on to the ASPX file. After successful logon, save the variable values in the Session to a table in the database. Use the SessionID of the Session object of ASP. NET, create an ASPX file, and obtain
Get the SessionID of the currently logged-on user and use the ASP. NET redirect statement to go to the JSP file. The URL request path format is test. jsp? Aspnetsessionid = ffj12d455p0ujr45vdqwhh45, if
ASP. NET is not logged on or logon fails. Although there is a SessionID value, the database does not have data associated with this SessionID.
Some readers may find that test. jsp is not required? Aspnetsessionid = ffj12d455p0ujr45vdqwhh45 and other request paths can also be completed. Yes, you can use test. jsp? Userid = 1111
The value is also passed. Of course, userid is the value obtained after ASP. NET is successfully logged on, but some users can know the sensitive data of USERID (user ID.
Create a table
Table name:
Iis_session
Field name:
Id varchar (26) -- stores ASP. NET SessionID
Userid int (4) -- stores the user ID after successful logon
Power int (4) -- store the user's permission number
Source code snippets of ASP. NET programs:
/* After successful logon, you can place the following CODEING in the logon authentication ASPX page */
// Record the Session value to the database
Private void WriteSession2DB (string sessionID, string sUID, string sPWR)
{
// Connect to the database code, which is automatically added by the reader
String sessID = sessionID;
String strSQL = "insert into iis_session (id, userid, power) values (@ seionID, @ UID, @ PWR )";
// Webmod. sqlConn is the connection object of the database. You can replace it with your own database connection.
SqlCommand sqlCmd = new SqlCommand (strSQL, webmod. sqlConn );
SqlCmd. Parameters. Add ("@ seionID", SqlDbType. VarChar). Value = sessID;
SqlCmd. Parameters. Add ("@ UID", SqlDbType. Int). Value = Convert. ToInt32 (sUID. Trim ());
SqlCmd. Parameters. Add ("@ PWR", SqlDbType. Int). Value = Convert. ToInt32 (sPWR. Trim ());
SqlCmd. ExecuteNonQuery ();
// Closes the database connection, and the reader adds

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.