Server.Transfer from ASP to ASP.Net

删除回忆录丶 提交于 2019-12-24 00:43:20

问题


Here's my scenario:

A desktop application posts to a specific ASP page in my web application with XML data. The web application is being re-written to ASP.Net; however, the Url for that specific page can not change (due to the desktop application).

My original idea was to simply 'forward' the requests from the classic ASP page to a new ASPX page, which would handle the request, by changing the ASP page like so:

<% Server.Transfer("MyApp/NewXmlHandler.aspx") %>

However, this doesn't work:

Active Server Pages error 'ASP 0221' Invalid @ Command directive /MyApp/NewXmlHandler.aspx, line 1

Is there a simple way I can take the posted data in the ASP page, and forward it on to another page?

Thanks!


回答1:


Put the form values into querystrings (URL encode them) and then use Response.Redirect instead. Server.Transfer resumes execution and you cannot execute an ASP.NET page in ASP 3.0.




回答2:


In case anyone else runs into this, I ended up passing the request along like so:

<%
    Dim postData
    Dim xmlhttp 

    'Forward the request to let .Net handle
    Set xmlhttp = server.CreateObject("MSXML2.ServerXMLHTTP")
    xmlhttp.Open "POST","http://127.0.0.1/MyApp/NewXmlHandler.aspx",false

    xmlhttp.send(Request)

    Response.Write xmlhttp.responseText

    Set xmlhttp = nothing
%>



回答3:


Can you use ASP.NET routing? If so, just route the POST to the .aspx page instead of the .asp page.




回答4:


I'm working on a similar problem just like this one but i have to deal with authorization also. In your case it is much simpler and for those who might run into this problem, I think URLRewrite or .htaccess will do the trick.



来源:https://stackoverflow.com/questions/1127733/server-transfer-from-asp-to-asp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!