Post xml to Asp.net page

Q

quest

My windows application (console application) posts xml (HTTP "POST") to
Asp.net page. My question is:

1. How should I code my Asp.net page so that it is able to 'detect' that
something is posted to it ?

2. How do I extract the xml from the html page ?

Thanks.
 
M

Mona

Hi,

I'm answering your both queries here:
For the first question:, you can use the Request.Form to detect whatever has been posted

to the ASP.NET page as follows:

Request.Form("fieldname")

Now for the second question, since Xml is being posted to the page, Do a request.form() of the fieldname
that contains the XML, store it into a string. Then use XMLDOcument to save it to an XML file or use XMLWRiter

HTH

Mona[Grapecity]
 
B

Bruce Barker

depends on how the console app is posting. if its a form post, then use
Request["fieldName"], if the body is just xml, use Request.InputStream, if
its a soap call, use the web service interface. it could also be a file
upload, or attachment. you will also need to know of any encofding schemes
used.

-- bruce (sqlwork.com)
 
Q

quest

Thanks for the information. I created a simple Asp.net application. Request.Form will work but exactly when I should do "Request.Form" ? Is there any event driven stuffs to deal with when a POST is detected ? Thanks in advance.

using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace MyWeb
{
public class WebForm1 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}


Hi,

I'm answering your both queries here:
For the first question:, you can use the Request.Form to detect whatever has been posted

to the ASP.NET page as follows:

Request.Form("fieldname")

Now for the second question, since Xml is being posted to the page, Do a request.form() of the fieldname
that contains the XML, store it into a string. Then use XMLDOcument to save it to an XML file or use XMLWRiter

HTH

Mona[Grapecity]
 

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