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

G

genc ymeri

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:
 
D

Derek Harmon

genc ymeri said:
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/rfc2616-sec10.html#sec10.4.6


Derek Harmon
 
G

genc ymeri

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top