I am doing a web development project where the web application needs to look good on all browsers (on Mac and PC - Win7 and Win8) and mobile devices (iPad, Windows Phone, Android, etc). So most of my testing can be done in my development machine - either by running an emulator from Visual Studio, or letting the browser (i.e. Safari) emulate iPad/iPhone resolution. This probably solved 95% of the issues and problems. But, then I still want to do a real device test - where I actually run the web application and browse to it from an iPad, or a Mac, from an Android phone, etc.
Of course - the ideal solution is just to put the web application somewhere on the internet (i.e. http://mytestwebsite.mydomain.com) and let the testing begin. But unfortunately, I do not have the luxury of a QA or test site. So I just have to run it locally.
I can set it up on my IIS, but that seems to be a hassle - removing/stopping my current site running in IIS, setting up this new site, creating all the permissions, app pool, etc. Too much overhead for simple testing. Can I just hit F5, or run the IIS Express and make it accepting external request - so I can hit the site from outside of my dev machine? YES!
Allowing everyone to access http://mydevmachine:80Open up an admin elevated command prompt and type in this command:
netsh http add urlacl url=http://mydevmachine:80/ user=everyone
Open up firewallNow, we need to open up the Windows Firewall for allow traffic to go through. In the same command prompt from above, type in this command:
netsh firewall add portopening TCP 80 IISExpressWeb enable ALL
Configure IIS ExpressLastly, we need to add our machine name into the IIS Express configuration. You can find the config file located in C:\Users\
<site name="Domain.Site.Mvc" id="4"> <application path="/" applicationPool="Clr4IntegratedAppPool"> <virtualDirectory path="/" physicalPath="c:\Projects\Domain.Site\Domain.Site.Mvc" /> </application> <bindings> <binding protocol="http" bindingInformation="*:12555:localhost" /> <binding protocol="http" bindingInformation="*:80:mydevmachine" /> </bindings> </site>
Now, I can start my site on my dev machine and then browse to it from separate machines, Mac machine, phone, tablets, etc by just going to http://mydevmachine/. With the exception of an iPad. For whatever reason, iPad does not allow browsing to a local machine name - it has to be a fully qualified domain name. I will write a solution to this on a separate blog post.