Visual Studio provides Cassini (a local only version of IIS for Web Projects in Visual Studio) for developers to test their projects on their systems without having to use the real IIS server. However, it also imposes a restriction that only the localmachine (OS on which Visual Studio is Installed) can access it. Following the steps here would allow us to go around this restriction and view a site hosted on the Cassini server from another host (machine or virtual-machine) which is on the network. This helps when doing cross-platform or cross-browser UI testing.
Perquisites:
- Remote Machine/VM.
- Fiddler 2 (download from here). TIP: We will use its reverse proxy capabilities.
Steps:
- If using a VM, make sure you are using the Shared Networking/Bridged Mode.
- Build and Run the web-application/web-project on Visual Studio and make sure you can access it on your local machine. Take note of the port on which is hosted.
- Start fiddler and open from the menu. Tools > Fiddler Options.
- Go to the ‘Connections’ Tab and make sure the option - “Allow remote computers to connect” - is check marked.
- Customize the “Fiddler listens on port:” to a port not used by any application on your system (e.g. 9999)
- Click [Ok] button to save these options.
- Press ‘Ctrl+R’ to Customize rules (You can also go to Rules > Customize rules). This generally opens the rules file in notepad (or the default editor)
- Find the function OnBeforeRequest (The rule files follows the Jscript syntax)
- At the end of this function add these line:
if (oSession.host.toLowerCase() == "192.168.2.6:9999"){ oSession.host = "localhost:58060"; } // The IP address is the original machine's (with Cassini) IP // the localhost:port is the application port on Cassini
- Run cmd.exe and renew your IP by doing an:
>> ipconfig /release followed by >>ipconfig /renew
- From your browser in remote machine/VM access IP:<Fiddlers port>. e.g.
You should be seeing the website, served from Cassini, on the remote machine!
Posted via email from Abhishek Dev