I use Requestl.Url in my ASP.NET MVC application to provide a new page the URL of a returning page. Everything works fine, until I tested my page on an android emulator.
There I used http://10.0.2.2/ to address my local host. But Request.Url gives me “http://localhost/”.
That is a problem, since “localhost” points to the real local host of the android phone and “10.0.2.2” to my PC’s host.
Why does ASP.NET replaces the IP-address by the localhost name? How can I prevent this?
Thanks, Konrad
If I am understanding your post correctly you are pointing the android emulator to your pc and it is redirecting you to localhost
1st note i should point point out if you are using the Cassini development server built in to visual studio you can’t do it like that as it will only accept connections from localhost
As the Android emulator is seen as an external device (even tho it is on your computer) Cassini will not likely accept these connections I’m not sure if that is related to the root cause of your problem or not tho
the other option is to set up a dummy URL for local debugging by adding an entry to your hosts file e.g. myapp.local or asp.localhost.app etc. and pointing it to your PC localhost you will need to likely use IIS Express or IIS full for the purposes of debugging and set it up to accept your host file entry as a binding for the given site you are using
I had to do something similar with a Windows iPhone emulator i was using