Calling Asp.net Web Api From Android Studio View
Solution 1:
By default C# Web Api isn't accessible out side the localhost
i.e., in your LAN network. What you have to do is goto your project path and inside your project folder there is one folder called .vs
which is hidden by default (you can see that by changing your Folder and Search options settings).
Now open .vs
folder and goto config
folder and there open applicationhost.xml
file using any text editor.
After opening find out the following line
<bindings><bindingprotocol="http"bindingInformation="*:6040:localhost" /></bindings>
And update above line like this
<bindings><bindingprotocol="http"bindingInformation="*:6040:localhost" /><bindingprotocol="http"bindingInformation="*:6040:*" /></bindings>
Where, 6040
is your project's port address. Save and exit from editor. Now this allows you to access the Web Api throughout your LAN connection. (some times you have to start Visual Studio with Admin Privileges).
Now in your Mobile Phone open any browser and type the address like this
http://169.254.80.80:6040
If you get some response from your api it works perfectly.
Solution 2:
You could check if that is your public IP, or check if it is accessible outside your domain, as your device should be outside your domain, also check if you have granted internet access in your manifest.
Solution 3:
you should change HttpsURLConnection to HttpURLConnection because your URL using protocol http not https
Post a Comment for "Calling Asp.net Web Api From Android Studio View"