Monday, June 27, 2011

Cannot Connect To IIS running On Windows 7

Today I tried to set up a web server connected to my wireless router. The objective was to be able to test a web site I’m working on. I have a Netgear N300 Wireless Dual Band ADSL2+ Modem Router model DGND3300v2. I am this specific for making it easier for people to find this blog post.

The first challenge was to set up the port forwarding. By default the wireless router blocks all connections that are initiated from the outside. Some people refer to this as incoming traffic allow this is strictly speaking not precise.

What you want to set up is an inbound rule for the HTTP service. There is a good description for how to do this on Netgear’s support site.

To make sure your web server doesn’t change it’s internal IP address you may want to assign a permanent address instead of using DHCP. Again this is easy to do. Just open the configuration tool on the router and go to the “LAN Setup” which is found under “Advanced” in the left hand menu. Don’t forget to click the “Apply” button!

At this point you should be able to see new entries in the log file of the router. These entries should show something like “Mon, 2011-06-27 20:51:18 - TCP Packet - Source:x1.x2.x3.x4,49402 Destination:y1.y2.y3.y4,80 - [HTTP rule match]” where x is the source IP address and y is the destination IP address. (For obvious reasons I have left them out of this post.)

You may still receive the “HTTP 504 error” which indicates that the web server is taking too long to responds. In my particular scenario it meant that it wasn’t answering at all. After quite some researching I found that on my Windows 7 machine the Windows Firewall had the rule “World Wide Web Services (HTTP Traffic-In)” disabled resulting in all inbound traffic on port 80 to be rejected. Since IIS is listening on port 80 by default there was no wonder it took too long …

After I enabled the rule thus enabling inbound traffic on port 80 all worked like a charm. I wrote this post hoping it may safe other people some time. Good luck!

BTW: I’m very satisfied with the Netgear N300 router. It works like a charm and I never had an issue with it. Prior to this I had a Linksys router, which needed a reset at least once a month and at times more than that because one of the computers at my place wouldn’t be able to connect unless I had rebooted the router. The Linksys router also didn’t have a reset button or a power button. To make it reboot I had to unplug it from the wall power outlet. The Netgear N300 router has a much better range, does 801.2n as well and support both 2.8 GHz and 5 GHz. If you look for a reliable router then I would strongly recommend to take a look at the Netgear N300. (No, I didn’t get it for free from Netgear and had to buy it like everybody else.)

Tuesday, June 21, 2011

BIN Deploying ASP.NET MVC 3 with Razor to a Windows Server without MVC installed

Scott Hanselman discussed in his blog some time ago the challenge with deploying MVC 3 applications where MVC is not installed on the server. He described several options.

I am not challenging that the different options that he offers come with different advantages and disadvantages. So it is essentially up to you to decide which option you want to use.

In this post I want to summarize the option that I used for a deployment where MVC 3 was not installed on the server. In a first step I created a web site project and inside of the project folder I created a folder that I named “mvc3”. Inside of that folder I copied the following assemblies:

  • Microsoft.Web.Infrastructure.dll
  • System.Web.Helpers.dll
  • System.Web.Mvc.dll
  • System.Web.Razor.dll
  • System.Web.WebPages.Deployment.dll
  • System.Web.WebPages.dll
  • System.Web.WebPages.Razor.dll

Next I added all of these as references to the web site project. In all cases I set “Copy Local” to “true” to make it would be picked up upon publication.

Finally I build the site and then used “Publish…” to get the web site onto the server.

With these changes is just worked like a charm.

If at some point the server supports MVC 3 out of the box then certainly you will want to remove the MVC 3 related assemblies.

This solution may not be the right choice for your scenario. Check Scott’s post for other options that may work better for you.