简体   繁体   English

使IIS7.5网站成为一个应用程序

[英]Make IIS7.5 Web Site an Application

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. 在IIS6中,我可以转到网站上的“属性”并从中创建/删除应用程序状态。 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. 最终,我的问题在于使用Visual Studio 2010中的“发布”功能,因为它给了我这个错误: 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. 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. 如果我在我的网站下创建一个虚拟目录并将其推广到一个应用程序(通过右键单击它并选择Convert to Application ),那么一切都很好。 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/ . 但我根本无法弄清楚如何对网站本身这样做,我需要这样做因为我需要这个MVC2网站托管在www.domain.com/而不是www.domain.com/appname/ Am I going about this all wrong? 我错了吗? Am I using VS2010 incorrectly or am I missing an option in IIS? 我错误地使用VS2010还是我错过了IIS中的选项?

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. 事实证明,问题与IIS及其配置或类似的东西无关,而是VS2010发布Web应用程序的方式的副产品。

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. 因此,正如我们大多数人所做的那样,我们并没有真正调试Cassini下的应用程序 - 相反,我们使用指向我们不断变化的源代码的IIS。 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. 好吧,使用发布功能的默认设置,VS2010的功能是编译应用程序(和依赖项),并将相应的文件复制到项目根位置内名为“obj”的特殊子目录下的文件夹中。 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. 其将要尝试部署的Web应用程序的“副本”中包含要部署的web.config文件。 This config file includes things that are meant to be in the web.config file in the root of the application. 此配置文件包含应该位于应用程序根目录中的web.config文件中的内容。 But keep in mind that our source code is inside an IIS application. 但请记住,我们的源代码位于IIS应用程序中。 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. 因此,一旦生成此文件(在我们编译/构建版本之后),我们现在违反了我们的dev / build机器上的IIS要求。

So this is all fine and good as long as VS successfully publishes the app and deletes that temporary copy. 所以只要VS成功发布应用程序并删除该临时副本,这一切都很好。 The only problem is that VS does NOT delete that temporary copy (in ~/obj/Release/Package/PackageTmp ) whether it is successful or not. 唯一的问题是VS不会删除该临时副本(在~/obj/Release/Package/PackageTmp )是否成功。 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. 因此,一旦您尝试发布一次,就无法成功编译您的应用程序而没有此错误暗示IIS配置中的问题,并且此错误将阻止将来发布。

So my work-around to this is to just delete the obj folder after I do a publish. 所以我的解决方法是在发布后删除obj文件夹。 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). 其他功能性解决方法包括将其设置为调试IIS应用程序目录路径之外的文件夹(对源控制系统有益)或在obj文件夹下为调试/发布副本添加IIS应用程序(具有其他潜在好处)。 All in all, this was a very confusing issue with some pretty simple work-arounds. 总而言之,这是一个非常混乱的问题,有一些非常简单的解决方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM