Asp.net and ASP sessions cannot be directly shared (the underlying processing DLL is different). To connect sessions, you can only use a work und:
I. Asp.net-> Asp session Transfer
A)Create a page similar to sessionhanler. asp,CodeAs follows:
<! -- # Include virtual = "INC/func. ASP "--> <% dim returnurl SESSION (" user ") = request (" user ") set returnurl = request (" returnurl ") if returnurl = "" Then returnurl = "home. ASP "end if 'Log appendfile"/log/log.txt ", now () &", user: "& SESSION (" user ") &", returnurl: "& returnurl response. redirect (returnurl) %>
The general function is to receive parameters, generate sessions as needed, and redirect to the real function page, so that other pages have a value when accessing the session.
B)Create an Asp.net page and submit the value to be passed to sessionhanler. asp (either post or get) as a parameter. Refer to the Code:
Using system; namespace asp_aspx_test {public partial class index: system. web. UI. page {protected void page_load (Object sender, eventargs e) {If (ispostback) {string returnurl = "home. ASP "; string sessoinhandlerurl =" sessionhandler. ASP "; string postdata =" user = "+ this.txt user. text + "& returnurl =" + returnurl; response. redirect (sessoinhandlerurl + "? "+ Postdata );}}}}
Ii. asp-> Asp.net session Transfer
In turn, the principle is the same.
3. Intercept ASP requests
For an existing ASP project, do not modify its ASPSource codeTo intercept HTTP requests (for example, process the intercepted Request Parameters and then send them to other subsystems. At the same time, it does not affect the normal operation of the original ASP project), there are two ways:
A)Develop the ISAPI filter by yourself, and add the DLL you have developed to the ISAPI filter in IIS.
This method is cumbersome, technical difficulty is relatively high, in today's. Net Era, do not recommend everyone to use, interested can refer to an open source project: http://filterdotnet.codeplex.com/
And ISAPI DevelopmentArticleFor example
ISAPI development Introduction http://blog.csdn.net/mycoolx/article/details/6913048
ISAPI tutorial for Delphi developers http://delphi.about.com/library/bluc/text/uc060901c.htm
Delphi iis isapi http://www.cnblogs.com/cisky/archive/2011/01/05/1926249.html
Delphi iis isapi http://siyebocai.blog.163.com/blog/static/103316426200810297512408/
Use Delphi to compile IIS ISAPIProgramHttp://download.csdn.net/detail/wwwvvingnet/2229146
Debug ISAPI program http://bbs.csdn.net/topics/7979 with IIS or PWS in Delphi
B)Use Asp.net's httpmodule (Environment: iis7/ASP. NET 4.0 passed the test)
Prerequisites:The application pool used by the ASP project must use"Integration"Mode
Create an httpmodule first
Using system; using system. io; using system. web; namespace asp_aspx_test {public class myhttpmodule: ihttpmodule {string logfilename; Public myhttpmodule () {logfilename = httpcontext. current. server. mappath ("~ /Log/request. log ");} public void dispose () {} public void Init (httpapplication context) {context. beginrequest + = beginrequesthandle; context. endrequest + = endrequesthandle;} private void beginrequesthandle (Object source, eventargs e) {httpapplication application = (httpapplication) source; httpcontext context = application. context; httprequest request = context. request; file. appendalltext (logfilename, environment. newline + request. URL + environment. newline + "beginrequest =>" + datetime. now. tostring ("yyyy-mm-dd hh: mm: SS") + environment. newline); foreach (VAR item in request. querystring. allkeys) {file. appendalltext (logfilename, String. format ("querystring => {0 }:{ 1}", item, request. querystring [item]) + environment. newline);} foreach (VAR item in request. form. allkeys) {file. appendalltext (logfilename, String. format ("form => {0 }:{ 1}", item, request. form [item]) + environment. newline);} context. response. write ("beginrequesthandle <br/>");} private void endrequesthandle (Object source, eventargs e) {httpapplication application = (httpapplication) source; httpcontext context = application. context; httprequest request = context. request; file. appendalltext (logfilename, environment. newline + request. URL + environment. newline + "endrequest =>" + datetime. now. tostring ("yyyy-mm-dd hh: mm: SS") + environment. newline); foreach (VAR item in request. querystring. allkeys) {file. appendalltext (logfilename, String. format ("querystring => {0 }:{ 1}", item, request. querystring [item]) + environment. newline);} foreach (VAR item in request. form. allkeys) {file. appendalltext (logfilename, String. format ("form => {0 }:{ 1}", item, request. form [item]) + environment. newline);} context. response. write ("endrequesthandle <br/> ");}}}
Here is just the Demo code. I recorded all the querystring and form parameters in the request.
Modify configuration in Web. config
<? XML version = "1.0" encoding = "UTF-8"?> <Configuration> <system. web> <compilation DEBUG = "true" targetframework = "4.0"/> </system. web> <system. webserver> <modules runallmanagedmodulesforallrequests = "true"> <Add name = "myhttpmodule" type = "asp_aspx_test.myhttpmodule, asp_aspx_test"/> </modules> </system. webserver> </configuration>
Note:Iis7 and later versions, custom httpmodule, must be addedSystem. WebserverNode. Otherwise, only Asp.net requests can be blocked and ASP requests are invalid.
Finally, I will give you a tips on ASP debugging. (Since Asp.net came out, many people probably haven't touched ASP for a long time, just like me. These tips are almost lost, so I will post them here to back up)
Remove it from IE browser firstFriendly ErrorCheck
In IIS settings,Allow sending detailed errors to the client
In this way, the detailed information is displayed when an ASP code error occurs.