Test and debug your ASP.NET sites on iPhone / iOS, Android, and other mobile devices locally with SharpProxy

ANOTHER update for 2014: Ok, so I’ve upgraded to Visual Studio 2013 now and I feel your pain with IIS Express. Check out the latest version version of SharpProxy with new support for rewriting HTTP Host Headers. That should fix your issues. Enjoy!

Update for 2014: I wrote this back when Visual Studio 2010 was all the rage. It came bundled with a little built-in web server that I believe is different from what more modern versions of Visual Studio use. I haven’t had a chance to use them yet, but I believe they are based on IIS Express. I’ve heard that this server doesn’t have the localhost restrictions that the original webserver did. With a little reading and some tweaks, you may be able to access it from your device over Wi-Fi. If you already have good information on this, please leave a comment with details! Thanks, and good luck!

Have you ever wanted to test and debug a mobile ASP.NET site on an iPhone, Android phone, Blackberry, or other mobile device? If so, you might have noticed that the development server packaged up by default with Visual Studio is a little bit… limited. It doesn’t allow anyone to access your local development web server, and will actually reject requests from outside your local machine outright.

Maybe this is a good idea for security. Maybe it was a decision made to keep people from using the development servers instead of getting a real IIS server. Maybe it was just easier to program when developing Visual Studio? I am really not sure what the official reason behind it was.

First, let me ask you a few questions about mobile web development issues with ASP.NET that used to be painful for me:

  • Ever had to push a site up to a development server every time you make a change?
  • Tired of waiting FOREVER for sites to publish after changes just so you can test them on your device?
  • Frustrated over not being able to use breakpoints after publishing to a remote server?
  • Sick of resynchronizing data every time you have to push a change to your development server?
  • Ever wished you could share changes from your local machine without overwriting or waiting to republish on development?

I sure hope these are things that make you mad, because they were pissing me off to no end. After doing a few full mobile sites with ASP.NET I could literally take no more. I decided to come up with a solution. Maybe it’s not the best solution, but I needed something that would solve these problems for myself and people on my teams.

I decided to go for a program that would open up the internal local port to another port of my choosing globally. All traffic is passed directly from one port to the other, internally, while being completely loss-less and unchanged. Since it’s written with the .NET framework and I generally call it like it is… I dubbed this project SharpProxy.

SharpProxy does what it can to keep things simple.

Using SharpProxy is easy:

  1. Take a peek at what port your local ASP.NET server has decided to use.
  2. Enter it in as the Internal Port
  3. Change the External Port if desired
  4. Hit Start

Finding your ASP.NET development server’s port

That’s it! Once you have SharpProxy up and running, you can connect your device to your internal Wi-Fi network and access the server via IP and port. In my case, the process looks like this:

  1. Configure and start SharpProxy
  2. Connect my iPhone to Wi-Fi
  3. Point Safari to

If I wanted to, I could setup a port forward from my router on port 5000 and use my public IP address or a dynamic DNS service. Hopefully how this all fits together is making sense – I trust you (the developer) are at least partially familiar with network scopes, firewalls and all of that. πŸ˜‰

Potential Pitfall: I really don’t think this will be a problem for most people. Still, you should be aware of it. This isn’t a problem with SharpProxy, rather it is a problem with redirections in general.

When using this with our CAS authentication server at work, I noticed that sometimes the redirects from our projects were wrong. I corrected for our case by making sure I redirect back from CAS to whatever the requested host was – NOT localhost.

In code, you can detect what the base host is by doing something like this from an ASP.NET MVC site’s controller. I think it should also work from an older ASP.NET web forms project also.

Update… you may not need to do this anymore with the new host headers option. I haven’t tried anything surrounding this issue yet. Or it may simply not work. Who knows! Comment if you have problems.

string baseURL = "http://" + this.Request.Headers["Host"];

To conclude, I hope that SharpProxy can be useful for you. I’ve published the source on GitHub, so feel free to get a copy of it, or just download and use the executable (requires the .NET 2.0 framework or greater). It may work in Mono also, but I haven’t tested it.

It’s free as in beer! (That means it’s really free, no license.) If you like using it feel free to talk about, write about it, link to it, or donate a few dollars into my PayPal. That would be super cool!

Download SharpProxy
(Built against the .NET 4.0 framework)

Get the source code on GitHub

About James

I own this site. I love code. The end?
This entry was posted in productivity, Programming, Web Programming. Bookmark the permalink.

98 Responses to Test and debug your ASP.NET sites on iPhone / iOS, Android, and other mobile devices locally with SharpProxy

  1. Hank says:

    You are a legend. I’ll buy you a beer.

  2. James says:

    Glad you like it! It was fun to develop.

  3. Pankaj Doshi says:

    Will this work for an android phone ?
    I have made a web application in asp.net , so it is possible to see the webpages created in asp.net from my android phone
    Also what if I don’t have an internal Wi fi …can GPRS/EDGE be used ?

  4. James says:

    @Pankaj – Absolutely! The only thing you will have to do is forward your external port to your public IP address if you are behind a router or firewall. That should work if you are coming from 3G, EDGE, etc… Good luck!

  5. Nutan says:

    I tried using this tool but not working in my case.When I try to test my application on Android and Blackberry simulators. It is not able to access my asp.net mvc3 application. I did the steps you mentioned above.

    • James says:

      @Nutan – Simulators may be a special case. I’m not sure if they do NAT or not, but you may try just using the original localhost address with the weird port that .NET provides. I think a lot of simulators just share your internal address. Accessing the local server shouldn’t be a problem from there.

  6. Pingback: asp.net, c#,javascript

  7. Great stuff James. I’m using this to test our mobile site on Android and iPhone. Worked like a charm.

  8. Tu Tran says:

    Thanks very much for your excellent tool. But when i point safari to http: which is my IP and port (58767), i got HTML 404 error, Can you help me with that ?
    Tks again

    • Tu Tran says:

      Sorry, meant HTTP 404 error

      • James says:

        @Tu Tran – Hmmm, getting a 404 error means that it got something at least. Try accessing the site from your local computer using the loopback at and see what happens then.

        • Tu Tran says:

          i had the same error πŸ˜€
          by the way, im using 3g broadband network, is it the reason why i get this error?

          • James says:

            @Tu Tran – If you’re getting the same error it must be some kind of internal problem. Try stepping through your code or figuring out if you need to point it to some kind of subdirectory. Watch where it launches you to when you debug the website, then use that path off of your loopback address and port. Testing on 3G should be fine, but you will have the make sure your IP and port are both publicly accessible. That might require port forwarding.

          • James says:

            @Tu Tran – Ah ha! Your site is clearly live, because I can see it right now πŸ˜‰ Try using this path after the port! — /PEx-Parramatta-E-Valuation/Home.aspx

          • Tu Tran says:

            Tks James, i can get it work now πŸ˜€

  9. Ryan says:

    sweet. This port forwarding allowed me to open my local dev server to an open port so others on the network can review. Thanks!

  10. Tom says:

    Couldn’t you just set it up to run on IIS locally?

    • James says:

      @Tom Absolutely! I like this a little better because it’s easy to snap into the built in dev server. It makes quick debugging easy and you don’t have to worry about redeploying after each build / reattaching the debugger. Also nice for people who might still be using XP boxes – IIS 5 loses out on wildcard extension mapping used by ASP.NET MVC.

  11. StevenStewart says:

    Yet another accolade. I was so over this and I said “I bet I could write a proxy to fix this problem.” But thought first I should google, because I bet someone has.

    You, sir, win the internet.

    Seriously, thanks for this!

  12. Darcy Rayner says:

    Really handy, thank you for making my life that little bit easier.

  13. javqui says:

    Really useful. Thanks!

  14. Lee says:

    Too easy! Cheers!

  15. manman says:

    hello everyone, may i ask if what may cause if the problem is that it cannot be accessed by other network from other places, geographically speaking? i have tested it using an iphone and it worked (within same router), however, when i tried to let others look into it, it did not work. what do you think is the problem here and its corresponding solution/s? thanks πŸ™‚

    • James says:

      Manman – It’s likely a port forwarding / firewall problem. You’ll need to open a port on your network to allow external testing.

  16. awesome tool, works like a charm (using it to test Jquery Mobile pages & mvc4 as framework)

  17. Eduardo Silva says:

    I’ve already tested others port forwarding tools, that did not work well with ASP NET Development Server, but this one is great. Thanks for sharing!

  18. Pradeep says:

    // send login request to the webservice

    String SOAP_ACTION_LOGIN = “http://tempuri.org/AuthenticateUser”;
    String METHOD_NAME_LOGIN = “AuthenticateUser”;
    String URL_LOGIN = “”;

    Hi , James this is the way i am connecting using android emulator to my Web Service where host using local host ASP.NET Dev server
    if i want to connect this service (http://localhost:100/Service1.asmx?op=AuthenticateUser ) using android real device using WI-FI what are The Steps i want to Follow
    User Windows 7 , android 2.2

    • James says:

      @Pradeep – That seems okay to me… try double checking your IP address and ports? The Android emulator’s address may be behind NAT, but I kind of doubt it.

  19. Sam says:

    Is this intended to work with IIS express in VS2012?

    I get the following error.

    Bad Request – Invalid Hostname

    HTTP Error 400. The request hostname is invalid.

    • James says:

      @Sam – I haven’t tested it with IIS express. My guess is that you will need to add another host header for your IIS site that ties to the external IP address you wish to use?

    • Kyle says:

      I had this problem as well with VS 2012 and IIS Express.

      You can fix this problem by right clicking on your project and going to Properties > Web > Servers. Select the “Use Visual Studio Development Server” option. Keep in mind that the internal port number may change now for your project. Rerun your project, restart SharpProxy and you’re good to go!

  20. Adriano Ávila says:

    Great application, but unfortunately its not working for me. IΒ΄m trying to access my web site from a android device, and iΒ΄m always getting an “error 400. bad request. invalid hostname”. I also created a rule in windows firewall to allow the port used by iis express, but doesnΒ΄t work.

  21. Parag says:

    This is awesome. After looking for a solution for hours, YOU my friend are the Solution πŸ™‚ Keep up the good work. Great work.

  22. Osi says:

    IIS express in VS2012 does not allow proxies to connect to the development server. This project has created a workaround which seem to work: http://opensource.oxyva.nl/simple-development-proxy

  23. arnel says:

    yes!!!finally..its working for me..i tried opening this for web services and it also worked..

  24. Alias says:

    Thank you thank you veeeeeeeeeeeeeeeeery much ,i’ve been looking for this solution the whoooooooooole week end you saved my life πŸ™‚ πŸ™‚ πŸ™‚

  25. Awesome! Saved me an hours headache as a junior dev! Thanks man

  26. Morten Olesen says:

    You are a lifesaver πŸ™‚ Very nice solution. It works perfectly!

  27. gator says:

    Great little tool, good job! Have been using it for testing an ASP.NET application on iOS and Android. However, I just noticed that after some idle time I can’t access the application via a mobile device over WiFi any more (accessing the application from my PC using the external port is fine though)..I need to stop and restart SharpProxy for it to work again..wondering why it is so..thanks..

    • James says:

      I’ve seen similar things happen in other applications but I am never sure why… Perhaps there are too many stalled TCP threads? Maybe the timeout needs to be faster or something?

      • gator says:

        Hi James, now I’m not able to connect via my smart phone at all..I start my ASP.NET development server, then SharpProxy..I load my application using the external port and my IP address on my PC which works fine…however, when I do the same using my iOS/Android device connected over the same Wifi network I get a Web page not available message…sigh

  28. LoveCode says:


  29. veerendra kumar reddy says:

    hi sir i developed one web application online examination portal the client wants that portal to anroid app how i convert asp.net website into android app like facebook is php but andriod app avialbel and also ticketdada is also aps.net website it is also avialbel like andriod app please help meeeeeeeeee

  30. Guy says:

    This is really awesome! You have saved me a lot of time here. Thank you so much. Again, this was a great idea and solution.

  31. Andrew Spear says:

    Wow, I spent literally half a day trying to work around this issue in different ways, messing with hosts files on both machines, changing a bunch of settings on Parallels and in Windows, even trying Windows-based iOS simulator (all sucked), via a dozen StackOverflow posts…

    Then I found SharpProxy and in less than a minute I had my native Xcode iOS Simulator running my VM .NET development environment (via Parallels). This is fantastic, thanks!

    • James says:

      Excellent! One thing to check as I’ve run into something similar with VMware. VMware creates an “internal” network for all of your NAT’d machines. This is all fine and dandy, but since Windows can’t determine what kind of network it is it makes it “public”. Often I disable the firewall for non-public networks, but leave it enabled for public. All the traffic ends up getting blocked because of the firewall settings!

      I still use Visual Studio 2010 in my day-to-day, so SharpProxy is great here. However, I hear that new versions of Visual Studio package in IIS Express – making the ability to browse remotely possible. Just another thing to think about! πŸ™‚

  32. AndroidStarter says:

    It worked like wonder for me πŸ™‚
    Thanks allot Bro you are a life saver !!!
    I was searching for how to access local host from my android app i just created that used .net web services and finally i got solution!!
    Thanks again

  33. Jeff B says:

    Thank you, this app is awesome and should be shipped as part of the Visual Studio suite.

  34. Matthew says:

    This is not working with VS Express 2013 for Web πŸ™
    I get 400 Bad Hostname.

    Anybody have any how to make it work?

    • James says:

      You may not need this when using that version of Visual Studio. Check the documentation for IIS Express, as I think that is the default web server. It shouldn’t require you to use SharpProxy as it isn’t limited to internal connections only.

    • James says:

      I’ve fixed this issue with the latest update. It allows host header rewrites. Enjoy!

  35. Samih says:

    Thanks a lot,

  36. James says:

    Awesome. Such a simple workaround to such a horrible problem. Colour me impressed.

  37. kaixuan says:

    Great!!! I love this little and powerful tool.

  38. Kovendan says:

    Hi sir,
    mobile connected with wifi from local server but i can’t get it ma Mob browser.Even if connects in IIS , its working other computers bt not in Mobile.Is there any reason for this failure.What kind of browser should i use it in am Mobile to View the Web application.

    • James says:

      Any browser should work. You can attempt to view the IP information in your device’s settings to see if they are on the same network. Other than that, check for firewall issues. Antivirus programs can also block sometimes.

  39. Rajesh says:

    I followed What u said but still am not getting the result in ma Mobile Browser ji…
    1.Any Specified Mobile Browser for getting the result???
    2.Am connecting ma pc with Mobile using Wifi …but still i have some doubt regarding Connection.So help me how to find Whether Mobile is connected with Pc using Wifi….IS there any checking????

    Waiting for your kind reply

    • James says:

      You can attempt to view the IP information in your device’s settings to see if they are on the same network. Other than that, check for firewall issues.

      • Rajesh says:

        Hi sir,
        My mobile is connected via wifi only & Ipaddress also perfect.Am using VS2010 ultimate ,But still i can’t able to connect it.
        Please explain about Firewall issues other than adding inbound rule for the corresponding port number ,if any…

  40. Rajesh says:

    Will this Shareproxy works in VS2008???

  41. Rajesh says:


    I found a thing that “Port 8080 which am using in IIS is Closed “…Not only 8080,mostly all ports are closed …What is the procedure to open it …
    And Shareproxy works using Port Forwarding…Rit???
    Whether this might be the reason for not getting the output in ma mobile in localhost???
    Help me yar!!

  42. Nilesh says:

    Thank You So much frends πŸ™‚

  43. Pingback: Teste and Depure seus ASP.NET WebServices locamente | Lealpjm

  44. Anthony says:

    Worth noting that this is very handy for ‘Edit and Continue’ in Visual Studio

  45. Jenn says:

    Thank you so much for developing this! I just spent hours futilely researching how to accomplish this. Then I stumbled upon your blog and had it working within 5 minutes!

    • James says:

      Glad it helped! It used to be a huge pain in the older version of Visual Studio. IIS Express in the newer editions help, but it’s still rather annoying to configure!

      • Jenn says:


        I was wondering if it’s possible to use this for an application that needs to run 2 separate sites simultaneously? Basically, we recently changed our .NET solution so that in development our app runs on one localhost site while getting resources from a CDN on another localhost site. Is that possible with sharpProxy?

        In any case, like I said in my comment above, this program has been super helpful for us, so thank you for sharing it!

  46. Sebastian Ezequiel Balazote Oliver says:

    Man u are a life-saver! Amazing Job!

  47. Therapyx says:

    You are GOD! =) Thanks. It works awesome!

  48. Alex R says:

    Awesome, the most useful piece of software I’ve downloaded this year!
    I can debug my website on any mobile device while running it in Visual Studio.
    Many thanks!

  49. zai says:

    wow!!,, my problem is how to see my project using phone. and here you are James…
    THANKS A LOT.. it work..

  50. Ramya says:

    Really cool one. Awesome!!!

    Searched lot and nothing was so easy. Saved my time:)

  51. Chris says:

    Hey James,

    just wanted to leave a big fat THANK YOU for SharpProxy. It saved my day and will probably continue to be incredibly useful for our internal testing and debugging. If we ever meet, I’ll buy you a beer.

  52. Wyatt says:

    You are a saint

  53. Arash says:

    Thanks Dude , thats worked.
    now you can access this Address :
    through this address below:
    You are awesome

  54. Mahesh says:

    Tried everything
    – Firewall settings for port
    – applicationhost.config
    – IISBindings
    – Virtual direction with Computer name and so on , nothing worked.
    somehow got here, and it worked like charm. thanks mate.

  55. Rao says:

    This is an awesome utility, have been using this for last one year. Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *