473,322 Members | 1,347 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Http Post error (405) Method Not Allowed.

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.


Feb 27 '07 #1
3 5828
Thus wrote 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.
And that's the problem. You cannot post to a static HTML page. What's that
supposed to do? Replace the HTML page with an ASP.NET page.

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Feb 27 '07 #2
Well, actually, you can post to an HTML page, for example, the .html could
be a CMS site or a site that works with perl or other such script... It
could even have been mapped to use the .net stuff from within IIS.

However, one issue that you could have is that the XML code itself is being
stopped by the security for your app. If your destination page is actually a
remapped .aspx page, then in your page directive at the top (for your
destination page), you will need validateRequest="false"

However, doing this will allow scripts and whatnot to be saved into the
page. It is disabled by default to prevent cross site scripting. If you are
happy with it, then that is how you would do it.

Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"Joerg Jooss" <ne********@joergjooss.dewrote in message
news:94**************************@msnews.microsoft .com...
Thus wrote 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.

And that's the problem. You cannot post to a static HTML page. What's that
supposed to do? Replace the HTML page with an ASP.NET page.

Cheers,
--
Joerg Jooss
ne********@joergjooss.de


Feb 27 '07 #3
Thus wrote David,
Well, actually, you can post to an HTML page, for example, the .html
could be a CMS site or a site that works with perl or other such
script... It could even have been mapped to use the .net stuff from
within IIS.
You cannot post to a physical HTML *page*. You can post to a server side
application module that happens to be mapped to the *.html extension, which
I assumed isn't the case here.
However, one issue that you could have is that the XML code itself is
being stopped by the security for your app. If your destination page
is actually a remapped .aspx page, then in your page directive at the
top (for your destination page), you will need validateRequest="false"
The OP's code doesn't post form data, but plain old XML. Request validation
doesn't apply here.

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Feb 27 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: | last post by:
A friend of mine has a website that is ASP. I know nothing about ASP. He switched hosting and now his "contact us" form does not work. When you hit submit it gives an error "Error 405 Method not...
5
by: RK | last post by:
I am getting the "HTTP /1.1 405 - method not allowed" error when I am sending XML string over Msxml2.XMLHTTP object. I am sending data in POST, also passing querystring variable and here is the...
2
by: genc ymeri | last post by:
I'm uploading a text through http server but I keep getting the below error. Is the below error coming from my code or from the http server ???? Any help/tip will be very much appreciated. Thank...
0
by: Klem | last post by:
I am doing HTTP post and I am receiving the following error: System.IO.IOException: Unable to write data to the transport connection. ---> System.Net.Sockets.SocketException: An established...
2
by: GlennLanier | last post by:
Hello, I've searched the forums and can't find an answer -- if it i there, kindly point me in that direction. I would like to simulate a browser POSTing a FORM and be able to pars the response....
2
by: Niraj Ranka | last post by:
Hello, I am trying to use XML Http objects via Javascript to get the values from some websites. When i am checking it on local machine it is working fine. But when i upload the same of my web...
3
by: Steve Young | last post by:
I am trying to use the webclient class in VB.Net ... in particular I want to upload a file to the web server using: dim responseArray As Byte() = myWebClient.UploadFile(uri,"POST",filename) ...
0
by: John | last post by:
Hi, I am getting this error message The remote server returned an error: (405) Method Not Allowed. while trying to execute the following code: Dim myReq As HttpWebRequest =...
0
by: kokababu | last post by:
Hi, I have a simple rest web service which is running in the Tomcat. I tested my web service successfully using REST Client for FireFox. Now, I used PHP socket to post xml as string to my web...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.