John
John

Reputation: 17471

Server.Transfer from ASP to ASP.Net

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!

Upvotes: 3

Views: 3719

Answers (4)

iam-chief
iam-chief

Reputation: 1

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.

Upvotes: 0

John
John

Reputation: 17471

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

Upvotes: 2

Matthew Groves
Matthew Groves

Reputation: 26096

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

Upvotes: 0

Keith Adler
Keith Adler

Reputation: 21178

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.

Upvotes: 2

Related Questions