By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,271 Members | 1,267 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,271 IT Pros & Developers. It's quick & easy.

Uploading //The remote server returned an error: (405) Method Not Allowed.

P: n/a
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();

MyStream = MyClient.OpenWrite(SaveAddress, "PUT");
MyStreamWriter = new System.IO.StreamWriter(MyStream);

//grab the stream and write the output.
MyStreamWriter.Write(textOutput.Text);

//close the writer.

MyStreamWriter.Close();
MessageBox.Show("File has been created!");
}
catch (System.Net.WebException ex)
{
MessageBox.Show(ex.Message);
}


Error:
An unhandled exception of type 'System.Net.WebException' occurred in
system.dll

Additional information:
Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies

P: n/a
"genc ymeri" <ge********@hotmail.com> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl...
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 ? : : MyStream = MyClient.OpenWrite(SaveAddress, "PUT");


The message is coming from the HTTP server, it's an HTTP
status code. This means your request was received by the
server, but it will not accept it.

The HTTP server is telling you that it doesn't support PUT for
the URL (SaveAddress) you're requesting, so it will do you no
good to send it HTTP requests that start out,

HTTP/1.0 PUT blah/blah.balah

because it will always respond,

HTTP/1.0 405 Method Not Allowed
Allow: GET, POST {possibly other methods, but evidently not PUT}

and be done with your request. See RFC 2616 for more explanation
on the significance of possible HTTP Status Codes, like 405,

http://www.w3.org/Protocols/rfc2616/...html#sec10.4.6
Derek Harmon
Nov 16 '05 #2

P: n/a
Should I set somewhere what kind of format the file I'm loading is ??? I'm
trying to load a simple small XML file in TomCat webserver but the error we
are getting is saying that is not multi-part form or something.

Any idea ???? Is that something we have to take care in C# web client ????

"Derek Harmon" <lo*******@msn.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
"genc ymeri" <ge********@hotmail.com> wrote in message

news:%2****************@TK2MSFTNGP12.phx.gbl...
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 ?

: :
MyStream = MyClient.OpenWrite(SaveAddress, "PUT");


The message is coming from the HTTP server, it's an HTTP
status code. This means your request was received by the
server, but it will not accept it.

The HTTP server is telling you that it doesn't support PUT for
the URL (SaveAddress) you're requesting, so it will do you no
good to send it HTTP requests that start out,

HTTP/1.0 PUT blah/blah.balah

because it will always respond,

HTTP/1.0 405 Method Not Allowed
Allow: GET, POST {possibly other methods, but evidently not PUT}

and be done with your request. See RFC 2616 for more explanation
on the significance of possible HTTP Status Codes, like 405,

http://www.w3.org/Protocols/rfc2616/...html#sec10.4.6
Derek Harmon

Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.