473,698 Members | 2,631 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.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.


Feb 27 '07 #1
3 5851
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********@joer gjooss.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********@joe rgjooss.dewrote in message
news:94******** *************** ***@msnews.micr osoft.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********@joer gjooss.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********@joer gjooss.de
Feb 27 '07 #4

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

Similar topics

1
2302
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 allowed" that "post" method is not allowed? I looked at the code which is: <form action="send_email.asp" method="post" onSubmit="return checkform();"> . Its there a file or application missing with the new hosting company? Any help would be greatly...
5
11006
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 code. Also error comes only sometimes. var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); xmlhttp.Open("POST", "test.aspx?qsVar="+qsVar, false); xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xmlhttp.Send(xmldoc);
2
17408
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 You very much in advance. try { //create an instance of the WebClient. System.Net.WebClient MyClient = new System.Net.WebClient();
0
1266
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 connection was aborted by the software in your host machine at System.Net.Sockets.Socket.BeginSend(Byte buffer, Int32 offset, Int32 size, SocketFlags socketFlags, AsyncCallback callback, Object state) at...
2
20174
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. I have the following code in my Page_Load (litResponse is defined a <ASP:Literal>):
2
1078
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 server it gives me the error of Permissions Denied. Any idea why so.... --
3
4107
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) When I try this I get Error 405 - Method Not Allowed diagnostic message. I have searched the help files in .Net and cannot find reference to this error. Can someone point in the direction of a place where I can learn more about this error ... and...
0
2916
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 = WebRequest.Create("http://127.0.0.1/virtualdirectory/")
0
1729
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 service. But I got HTTP/1.1 405 Method Not Allowed error. I used the following code: <?php
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8876
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7741
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4624
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2341
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.