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.G etBytes(xml);
HttpWebRequest request = (HttpWebRequest ) WebRequest.Crea te(url);
request.Method = "POST";
request.Content Length = bytes.Length;
request.Content Type = "text/xml";
using (Stream requestStream = request.GetRequ estStream())
{
requestStream.W rite(bytes, 0, bytes.Length);
}
try
{
HttpWebResponse response = (HttpWebRespons e) request.GetResp onse();
}
catch (WebException webEx)
{
this.Label3.Tex t = 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.