how do I post XML from an ASP.NET app to another web application

G

Guest

Within an ASP.NET application, how can I redirect to another URL and post the
XML as the body to that URL. The other URL may not be ASP.NET application
(but another internet application).

One of the solution I came up with is that on the source ASP.NET, I return a
stream that an an HTML page and have IE redirect it. However, to make use of
POST and post the XML body, I need to use an INPUT tag. I would like to get
rid of the INPUT tag and have it post just an XML while doing a redirect on
the client browser.

Thanks.
 
G

Guest

Hi Alexey,

The sender application is an ASP.NET application and is ours.

The best solution I came up with is to return an HTML document as use the
INPUT HTML tag to be able to do HTTP post. Example is below. I am not
satisfy with it because I want to post the body as an XML document which the
applicationp specifies. Currently, use the method below, the receiver will
get "name=abc".


<FORM METHOD=POST ACTION="http://localhost:4762/TestASP/Default2.aspx"
name="TestForm">
<BODY onload="OnLoad" language=vbscript>
Enter your name:
<INPUT NAME=your_name value="abc">
<INPUT TYPE=submit VALUE="Test this form" >
</BODY>
</FORM >
<script language=vbscript>
Sub OnLoad
Document.TestForm.submit
End Sub
</script>
 
B

bruce barker

the browser only supports a form post such as you are doing. you can use
XmlHttpRequest and javascript to do the post. it depends on what you
want to happen with the response.

-- bruce (sqlwork.com)
 
S

Steven Cheng[MSFT]

Thanks for Bruce's input.

Hi Alexey,

As Bruce has mentioned web page in browser display html based content and
does not naturally support post as a XMLDocument. Sure, you can write code
to post XML document to a remote url endpoint by using javascript + XMLHTTP
or HttpWebRequest(in server-side code). However, you can not also make the
current browser/page redirected at the same time.

Would you provide some more info on what the target server application
would expect and what your client application(the sender application) will
need to do after post such a XMLdocument? Normally, you can consider the
following approachs:

** use javascript+xmlhttp to post the document in clientcode and redirect
the page in script after that

** postback to server and use serverside ASP.NET code to do the posting and
redirect the response stream

How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
 
G

Guest

Hi Steven,

Thanks again for your valuable input. I have gone with your first
recommendation in which a HTML page is returned to client browser. The HTML
page will then automatically route to another URL via submit. The POST data
is assign to an HTML INPUT element.
 
S

Steven Cheng[MSFT]

Thanks for your reply Alexey,

I'm glad that it also helps some.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top