TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Aishwarya D
NA
105
6.8k
I want to post xml data in asp.net
Dec 15 2015 3:07 AM
Hi All,
I have created 2 webforms named as requester and responder. Here I want to some XML data in requester webform. Here is the coding for requester:
protected void btnPostXml_Click(object sender, EventArgs e)
{
System.Net.WebRequest req = null;
System.Net.WebResponse rsp = null;
try
{
string uri = txtURI.Text;
req = System.Net.WebRequest.Create(uri);
req.Method = "POST";
req.ContentType = "text/xml";
System.IO.StreamWriter writer = new System.IO.StreamWriter(req.GetRequestStream());
writer.WriteLine(txtXMLData.Text);
writer.Close();
rsp = req.GetResponse();
//Response.Redirect("Responder.aspx");
}
catch
{
throw;
}
finally
{
if (req != null) req.GetRequestStream().Close();
if (rsp != null) rsp.GetResponseStream().Close();
}
}
Responder:
Page.Response.ContentType = "text/xml";
System.IO.StreamReader reader = new System.IO.StreamReader(Page.Request.InputStream);
String xmlData = reader.ReadToEnd();
System.IO.StreamWriter SW;
SW = File.CreateText(Server.MapPath(".") + @"\" + Guid.NewGuid() + ".txt");
SW.WriteLine(xmlData);
SW.Close();
While Executing this program. It will throw an exception. Can any one help me with this coding.
Reply
Answers (
2
)
MVC
Jump one controller to another controller in MVC 4