1

I have 4 file upload controls in my website, each of them will access my file server using (HttpWebResponse)Request.GetResponse() the first upload is fast, but the second upload is very slow, but the third and fourth upload is fast also. All the files are the same. I use (System.Net.HttpWebResponse)Request.GetResponse(); because I want to access/get response a folder in that server.

I check my logs and it turns out that the all upload returns an error The remote server returned an error: (405) Method Not Allowed. So why in the second upload is slower, it took 20 seconds to get the response, but the rest of request is like a second.

This is my original code:

try
{
      Response = (System.Net.HttpWebResponse)Request.GetResponse();
      Response.Close();
}
      catch (Exception)
{

I already tried setting my Request.Proxy to null and also

using (Response = (HttpWebResponse)Request.GetResponse())
{
}

and also

<system.net>
 <connectionManagement>
   <add address="*" maxconnection="20"/>
 </connectionManagement>
</system.net>

and also

httpWebRequest.Abort();

So it turns out that (System.Net.HttpWebResponse)Request.GetResponse(); return an error. How do i close it?

Joseph
  • 653
  • 1
  • 12
  • 28

1 Answers1

0

If you are getting 405 responses for each request then for the moment you ought to concentrate your efforts on understanding why your requests to the file server are not allowed.

Are there other end-points on that server you can access? Do you have permissions to access that server?

This link to HttpStatus codes explains a little more about what the 405 means https://httpstatuses.com/405

The answers to this Stackoverflow question might get you started with regards to investigating your problem. Server returned HTTP response code: 405 for URL

EDIT

I'm also not certain as to why you say using Request.GetResponse creates a folder? https://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.getresponse(v=vs.110).aspx

Community
  • 1
  • 1
Daniel Hollinrake
  • 1,768
  • 2
  • 19
  • 39
  • I'm getting 405 errors on all request (Same files are being uploaded), but the first, third and fourth upload is fast, while the second upload is slower. Why the second upload is slow even if they are all 405 error when using `(System.Net.HttpWebResponse)Request.GetResponse();`? I think the problem is not in the method im using? – Joseph Feb 22 '17 at 09:12
  • I dont have actual access on the file server i am using, but the files are uploaded successfully. I always call the `(System.Net.HttpWebResponse)Request.GetResponse();` to create a folder (Same name) when uploading a file – Joseph Feb 22 '17 at 09:17
  • How do you know your files are uploaded successfully? Are the files distinct from each other?. – Daniel Hollinrake Feb 22 '17 at 10:49
  • I access it via url. Yes it is distinct to each other. I added timestamp in the end of each filename. – Joseph Feb 22 '17 at 14:24
  • Sorry for that. This is my request code `Request = (System.Net.HttpWebRequest)HttpWebRequest.Create(directory);` – Joseph Feb 23 '17 at 00:49
  • and then Request.Method = 'MKCOL' to create a folder – Joseph Feb 23 '17 at 00:56