有了web.config,就不能在虚拟目录里运行aspx啦?报告web.config出错
先在Visual Studio 2005里新建了一个Mypage.aspx页面,仅给它里面拖入一个Label控件,没有任何事件和操作,保存到
d:\mypack\WebSites\WebSite1下。点击调试按钮,弹出对话框,有两个选项。我选择“直接运行不调试”,弹出IE,Mypage.aspx页面就正确
展现出来了。
然后我在IIS中新建了一个虚拟目录Mysitename,指向E:\work,并设置成目录可浏览。然后把d:\mypack\里的WebSites文件夹(注意:不是
WebSite1文件夹)复制到E:\work下。打开IE,输入http://127.0.0.1/Mysitename/,单击页面里的目录WebSites进入,再单击目录WebSite1进
入,再单击Mypage.aspx打开,页面也可正确显示。
再回到Visual Studio 2005,点击调试按钮,弹出对话框。现在问题是,我倘若选择“添加一个新的Web.config文件并设置成允许调试”,
弹出IE,那么Mypage.aspx页面也能正确显示,只是在文件夹WebSite1下多生成了一个web.config文件。然而自行打开IE,输入
http://127.0.0.1/Mysitename/,单击页面里的目录WebSites进入,再单击目录WebSite1进入,再单击Mypage.aspx打开,页面就出错了?
总之,生成或不生成web.config,在Visual Studio 2005里都可调试成功,而在自行设置的虚拟目录里,只有在没生成web.config的情况
下页面能正确运行,当生成了web.config后页面就不能正确运行了。
出错信息如下:
Server Error in '/Mysitename' Application.
--------------------------------------------------------------------------------
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review
the specific error details below and modify your configuration file appropriately.
Parser Error Message: 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.
Source Error:
Line 24: ASP.NET to identify an incoming user.
Line 25: -->
Line 26: <authentication mode="Windows"/>
Line 27: <!--
Line 28: The <customErrors> section enables configuration
Source File: E:\work\websites\website1\web.config Line: 26
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42
请不要问我为什么要在IIS中新建了虚拟目录,我有我的苦衷。我只是不明白在虚拟目录中为啥就不能运行,请热心人给出理由,摆出理论!