views:

327

answers:

1

What I'm doing SHOULD be simple. In IIS6 I could just go to Properties on the Web Site and Create/Remove the application status from it. However, I cannot for the life of me figure out how to convert the Web Site itself (not virtual directories under it) an application!

Ultimately, my problem is in using the Publish feature from Visual Studio 2010 as it gives me this error: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS. I'm assuming this is because the web site is not configured to be an application.

If I go create a Virtual Directory under my Web Site and promote it to an application (via right-clicking on it and selecting Convert to Application), then all is fine. But I simply cannot figure out how to do that to a Web Site itself and I need to do that because I need this MVC2 site hosted at www.domain.com/ rather than www.domain.com/appname/. Am I going about this all wrong? Am I using VS2010 incorrectly or am I missing an option in IIS?

A: 

I've resolved my problem. It turns out the problem has nothing to do with IIS and its configuration or anything like that but is instead a biproduct of the way VS2010 publishes web apps.

So as most of us do, we don't really debug applications under Cassini - instead we use IIS pointed at our source code that we're continually changing. Well, with the default settings of the Publish feature, what VS2010 does is compiles the app (and dependencies) and copies the appropriate files into a folder under a special subdirectory called "obj" inside of your project's root location. Included inside of this "copy" of the web app that it is going to attempt to deploy is the to-be-deployed web.config file. This config file includes things that are meant to be in the web.config file in the root of the application. But keep in mind that our source code is inside an IIS application. So once this file is generated (after we have compiled/built the release), we are now in violation of IIS requirements on our dev/build machine.

So this is all fine and good as long as VS successfully publishes the app and deletes that temporary copy. The only problem is that VS does NOT delete that temporary copy (in ~/obj/Release/Package/PackageTmp) whether it is successful or not. So once you attempt to publish once, you cannot successfully compile your app without this error hinting at a problem in IIS configuration, and this error will prevent a future publish.

So my work-around to this is to just delete the obj folder after I do a publish. Other functional work-arounds would include setting this to a folder outside of your debugging IIS application directory path (has benefits with source control systems) or adding an IIS application for the debug/release copies under the obj folder (has other potential benefits). All in all, this was a very confusing issue with some pretty simple work-arounds.

Jaxidian