1

I have an MVC4 web application

In setting it up on IIS7.5 I added the application to the "Default Website" and set up a virtual directory under http://localhost/myApplication

However, this forced me to change many of my controller calls (specifically js ajax calls) which I previously called in Cassini like "/Home/Index", I now had to change them to "/myApplication/Home/Index" for them to work on my local IIS.

NOW, when I publish it to a remote hosting server I have to change it BACK to "/Home/Index" for it to work.

This cannot be the most productive way to traverse the development -> testing -> production cycle.. What step am I missing?

I tried to create the applications virtual directory on on just http://localhost/ without appending the application name so that I can call "/Home/Index" at all three stages but it complains that http://localhost/ is already mapped to inetpub/wwwroot.

Thanks for your time.

parliament
  • 21,544
  • 38
  • 148
  • 238

2 Answers2

2

The steps are like this:

  1. Publish your website to a new folder in inetpub/wwwroot (or the place where your applications are kept) like "inetpub/wwwroot/myapp"
  2. Go to IIS management, create a new web-site, assign it any free port (like 11001 or something, > 1024 at least) and point it to a folder from the step 1. Bind it to all IP addresses available or to 127.0.0.1
  3. Start the web-site.
  4. Access it using http://localhost:11001/ (or any other port you've set)

Problem is that by default any browser uses port 80 to request a web page, and that port is taken by the default web-site. You have to manually override it or create a site on another port. IIS usually warns you about port collisions.

Dmitry Reznik
  • 6,812
  • 2
  • 32
  • 27
  • Hm, this almost seemed to work until I got a 403 Forbidden after publishing to my remote hosting. Publishing to local IIS7.5 works but not to remote server. Can u suggest what I should do? – parliament Mar 26 '12 at 08:22
  • Wait a sec, nvm. I accidently published to mysite/wwwroot/wwwroot .... Everything works great thanks so much for showing me how to create a new site – parliament Mar 26 '12 at 08:32
1

If you don't want to have port number in the address, alternatively you can work with host header on port 80. You may have to make local host entry for the host header given to the site.