Asp.net|session
Recently to do a business processing system, because its original user system using ASP development, in the new business system used asp.net,asp.net application to use the original ASP user system, so the problem arises, ASP Application How to make the user login status and user information in the asp.net still valid. We then consider using the construct form to derive the session variables from the dynamic commit delivery ASP application.
Examples are as follows
ASP application URL for http://127.0.0.1/asp/, and in the ASP.net application of web.config settings
<!--set the url--> of ASP application
<add key= "Aspurl" value= "http://127.0.0.1/asp/"/>
Add two ASP pages system.asp and autopostform.asp in ASP applications
<!--system.asp-->
<%
Session ("UID") = "User"
Session ("Ispass") = "OK"
Server.Transfer ("autopostform.asp")
%>
<!--autopostform.asp-->
<%
Response.Write ("<form name=t id=t action=" "Http://127.0.0.1/aspdotnet/getSession.aspx" "
Method=post > ")
Response.Write ("<input type=hidden name=uid")
Response.Write ("Value=" & Session ("UID") & ">")
Response.Write ("<input type=hidden Name=ispass")
Response.Write ("Value=" & Session ("Ispass") & ">")
Response.Write ("</form>")
Response.Write ("<script>t.submit ();</script>")
%>
Use page getsession.aspx in asp.net application to accept the value of the session variable passed over
GetSession.aspx.cs Code fragment:
private void Page_Load (object sender, System.EventArgs e)
{
if (! Page.IsPostBack)
{
String aspurl=configurationsettings.appsettings["Aspurl"]. Trim ();
Try
{
String fromurl=request.servervariables["Http_referer"];
Verify whether to submit from ASP application
if (Fromurl. StartsWith (Aspurl))
{
String uid=request["UID"]. ToString ();
String state=request["Ispass"]. ToString ();
if (uid!= "" && state== "OK")
{
Indicates that the user has logged on successfully in the ASP system
}
}
Else
{
Response.Write ("<script>alert" (' illegal user or not logged in user '); top.location.href= ' "+ Aspurl +
"';</script>");
}
}
Catch
{
Response.Redirect (Aspurl);
}
}
}
Http://aspsir.cnblogs.com/archive/2005/12/24/41802.html