E
Eric
I'm trying to test code to post xml to a web page in anticipation of a new
project. I wanted to try a simple test first, but I get a (405) Method Not
Allowed error no matter what I try.
I have tried posting to the same machine as well as a different machine.
Anonymous access is enabled for the virtual directory.
I have added Allow POST for All Users for the virtual directory. I tried
allow All verbs for all users but the system said that was already in place.
Here is the code:
The destination url is http://localhost/XmlPost/XmlPost.html (as an
alternative I created the same setup on another machine). It doesnt do
anything.
The xml string is a simple xml block hard coded in the code for testing
purposes.
byte[] bytes = Encoding.UTF8.GetBytes(xml);
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url);
request.Method = "POST";
request.ContentLength = bytes.Length;
request.ContentType = "text/xml";
using (Stream requestStream = request.GetRequestStream())
{
requestStream.Write(bytes, 0, bytes.Length);
}
try
{
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
}
catch (WebException webEx)
{
this.Label3.Text = webEx.Message;
}
All changes I have tried have no effect and I cannot find anything on the
forums or google so far that has helped.
project. I wanted to try a simple test first, but I get a (405) Method Not
Allowed error no matter what I try.
I have tried posting to the same machine as well as a different machine.
Anonymous access is enabled for the virtual directory.
I have added Allow POST for All Users for the virtual directory. I tried
allow All verbs for all users but the system said that was already in place.
Here is the code:
The destination url is http://localhost/XmlPost/XmlPost.html (as an
alternative I created the same setup on another machine). It doesnt do
anything.
The xml string is a simple xml block hard coded in the code for testing
purposes.
byte[] bytes = Encoding.UTF8.GetBytes(xml);
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url);
request.Method = "POST";
request.ContentLength = bytes.Length;
request.ContentType = "text/xml";
using (Stream requestStream = request.GetRequestStream())
{
requestStream.Write(bytes, 0, bytes.Length);
}
try
{
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
}
catch (WebException webEx)
{
this.Label3.Text = webEx.Message;
}
All changes I have tried have no effect and I cannot find anything on the
forums or google so far that has helped.