user3064311
user3064311

Reputation: 23

WebClient HttpClient Upload From WP8

Seriously i search a lot upload file from WP8 to server. it's doesn't work :(

Why i get this error?? it's the error is because my FileuploadUrl?
System.Net.Http.HttpRequestException: Response status code does not indicate success: 405 (Method Not Allowed)

 private async void UploadFile()
    {
        try
        {
            if (photoStream != null)
            {
                 //var fileUploadUrl = @"http://<IPaddress>:<port>/fileupload";
                var fileUploadUrl = @"http://www.comevox.com:80/services";
                var client = new HttpClient();
                photoStream.Position = 0;

                MultipartFormDataContent content = new MultipartFormDataContent();
                content.Add(new StreamContent(photoStream), "file", fileName);

                await client.PostAsync(fileUploadUrl, content)
                    .ContinueWith((postTask) =>
                    {
                        postTask.Result.EnsureSuccessStatusCode();
                    });
            }

            btnUpload.IsEnabled = false;
            imgSelectedImage.Source = null;
            txtMessage.Visibility = Visibility.Visible;
        }
        catch
        {
            txtError.Visibility = Visibility.Visible;
        }
    }
}

Upvotes: 0

Views: 703

Answers (1)

DotNetRussell
DotNetRussell

Reputation: 9863

Fixing 405 errors - general

405 errors often arise with the POST method. You may be trying to introduce some kind of input form on the Web site, but not all ISPs allow the POST method necessary to process the form.

All 405 errors can be traced to configuration of the Web server and security governing access to the content of the Web site, so should easily be explained by your ISP.

Reference

Upvotes: 0

Related Questions