1

I'am develoing a VB.NET MVC4 Web App using Android's webView to run it.

I have the next problem: When i make an ajax PUT request to my own controllers method, i recieve a 404 status code.

In the other hand, when i make a get or post petition, works fine. ¿Any idea?

$.ajax({
                type: 'PUT',
                url: 'myurl',
                data: data,
                success: function (json, textStatus) {
                   alert(json);
                },
                error: function (jqXHR) {
                  alert('error');
                }
            });


jqXHR.readystate = 4
jqXHR.message = server error file or directory not found
jqXHR,status: 404

EDIT: IIS is configured to work with PUT and DELETE and thanks to that it works correctly in the browser but not with the Androids WebView.

user1826240
  • 95
  • 10
  • the first thing you need to do is narrow down the error. Are you sure it is solely related to the call being in an android webview? Are you sure your server actually supports PUT requests? – njzk2 Jul 15 '14 at 12:57
  • I do not think this has anything to do with android, have you tested it in a desktop browser? My guess is you get the same result. Re-tag with .NET and MVC4 and update your post with your server's routes map. It's probably something with that. – slf Jul 15 '14 at 13:00
  • When i test in my computers browser (chrome), works fine. ¿can you explain me in more details what are you talking about please? Thnaks for all. – user1826240 Jul 15 '14 at 13:07
  • The error is IIS does not as standard support `PUT, DELETE` ect.. so they have to be enabled – Barkermn01 Jul 15 '14 at 13:22

1 Answers1

0

Your code is missing a quote url: 'myurl needs a ' on the end

$.ajax({
    type: 'PUT',
    url: 'myurl',
    data: data,
    success: function (json, textStatus) {
        alert(json);
    },
    error: function (jqXHR) {
        alert('error');
    }
});

This might be an error in your example but that's all we can see to correct the other things to check is IIS Setup of the site does is it set to allow PUT, DELETE ect

GET & POST are standard and are enabled by default.

So please follow the answer to this question: How do I enable HTTP PUT and DELETE for ASP.NET MVC in IIS?

Community
  • 1
  • 1
Barkermn01
  • 6,781
  • 33
  • 83
  • First of all, thanks to everyone. Martin Barker you are true, there was a mistake on the example. As i said before, IIS is configured to work with PUT and DELETE and thanks to that it works correctly in the browser. Should I do something special to work with the Androids webview? Is it compatible? Thanks for all again. – user1826240 Jul 15 '14 at 19:06
  • The Android WebView is a WebKit implementation so it should fully support it im not sure why it would not, are you able to setup remote debugging of the Remote WebView i believe you can connect it to your chrome if I remember correctly https://developer.chrome.com/devtools/docs/remote-debugging see if you get any network information for the PUT, DELETE and such – Barkermn01 Jul 18 '14 at 11:45
  • After some test, I have deduced that until at least Android 4.2 does not support PUT operation, so i have modified to POST. Really, POST was a better solution to my problem. Thanks again to everyone. – user1826240 Jul 21 '14 at 06:07
  • There is another option.... i dont know if it will work but it would be worth you having a test and thats to use Cordova they added lots of little bit's to the WebView they used to support stuff so see if you can just move your mobile application HTML/CSS/JS files into a cordova application, if you having problems understanding how to setup cordova you can use a system called Telerik and that will build an APK for you. (it's paid but had a free trial) – Barkermn01 Jul 21 '14 at 12:50