Server.Transfer的从ASP到ASP.Net(Server.Transfer from

2019-09-18 20:45发布

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!

Answer 1:

把表单值到查询字符串(URL编码他们),然后使用Response.Redirect来代替。 Server.Transfer的继续执行,你不能在ASP 3.0执行ASP.NET页面。



Answer 2:

万一别人运行到这一点,我结束了传递请求一起,像这样:

<%
    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
%>


Answer 3:

你可以使用ASP.NET路由? 如果是这样,只是路线POST到.aspx页面,而不是.asp页。



Answer 4:

我工作的一个类似的问题,就像这一个,但我也必须处理授权。 在你的情况要简单得多,对于那些谁可能会遇到这个问题,我觉得URLRewrite或会的.htaccess做的伎俩。



文章来源: Server.Transfer from ASP to ASP.Net