appcmd created site ignoring asp.net web.config file with iis 7

If I make a site manually via the inetmgr app (IIS 7) and give it a site name and physical location (as well as changing its app pool to .net 4) it all runs fine and picks up the web.config file.

However if I set up the same site on the command line using appcmd it for some reason ignores the web.config file, the inetmgr shows the site working and the files being there, but under "Configuration Editor" there are no entries there from the web.config file.

The command line app cmd is run from a build script, but the method to do this is below:

def create_web_site(site_name, site_location, site_port)
  delete_command = "#{$file["appcmd"]} delete site #{site_name}"
  result = system delete_command
  puts "Failed to delete site on IIS: #{$?}" unless result

  add_command = "#{$file["appcmd"]} add site /name:#{site_name} /bindings:http/*:#{site_port}: /physicalPath:#{site_location}"
  result = system add_command
  raise "Failed to add site on IIS: #{$?}" unless result

  set_app_pool_command = "#{$file["appcmd"]} set app #{site_name}/ /applicationPool:\"ASP.NET v4.0\""
  result = system set_app_pool_command
  raise "Failed to bind site to .net 4 app pool on IIS: #{$?}" unless result

  start_site_command = "#{$file["appcmd"]} start site #{site_name}"
  result = system start_site_command
  raise "Failed to start site on IIS: #{$?}" unless result
end

You don't really need to know rake/ruby to see it is running appcmd and deleting a site if it exists, then adding the new one, using the .net 4 app pool then starting the site. This all works fine and I can see the 2 sites which are identical as far as I can tell (other than the one I am manually creating via the GUI has a different port to the other to stop conflicts).

Is there something im missing from appcmd which the GUI does for you when setting up sites?

Answers


After tinkering around the issue is down to the slashes between folders being incorrect for IIS. It all appears to work but wont pick anything up, so where my site directory was something like:

c:/some_folder/some_site

in my script I had to swap them to:

c:\some_folder\some_site

Everything worked fine, however as the "\" character usually signifies a skipping or ignoring on the following character I just did it as a string replace on the first string rather than entering it in as the correct way to begin with.


Need Your Help

PHP sort an array of array

php algorithm

I have the folloring array structure:

Logistic regression: 'odds ratio' is essentially just the ratio - what's the point?

r math logistic-regression

Trying to understand the use of logistic regression. I have the following data: