正如@BNL說我從this站點引用答案,
步驟1(IIS 7或IIS 7.5只)
這一步是必要只在運行的操作系統IIS 7或IIS 7.5,其中包括Windows Vista,Windows Server 2008,Windows 7和Windows Server 2008 R2。
將父應用程序(運行ASP.NET 2.0或ASP.NET 3.5的應用程序)的Web.config文件中的configSections定義移動到.NET Framework 2.0的根Web.config文件中。 IIS 7和IIS 7.5本機配置系統在合併配置文件的層次結構時掃描configSections元素。將configSections定義從父Web應用程序的Web.config文件移動到根Web.config文件,有效地隱藏了子ASP.NET 4應用程序出現的配置合併過程中的元素。
在32位操作系統或32位應用程序池,用於ASP.NET 2.0和ASP.NET 3.5通常位於下面的文件夾根Web.config文件:
C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG
在64位操作系統或64位應用程序池,用於ASP.NET 2.0和ASP.NET 3.5通常位於下面的文件夾根Web.config文件:
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG
如果運行都32位和64位Web應用程序在64位計算機上,您必須將configSections元素向上移動到r用於32位和64位系統的Web.config文件。
當您將configSections元素放入根Web.config文件中時,請將該部分粘貼到配置元素之後。以下示例顯示完成移動元素後,根Web.config文件的頂部部分應該是什麼樣子。
注意在下面的示例中,爲了便於閱讀,行已換行。
<?xml version="1.0" encoding="utf-8"?>
<!-- The root web configuration file -->
<configuration>
<configSections>
<sectionGroup name="system.web.extensions"
type="System.Web.Configuration.SystemWebExtensionsSectionGroup,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="scripting"
type="System.Web.Configuration.ScriptingSectionGroup,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35">
<section name="scriptResourceHandler"
type="System.Web.Configuration.ScriptingScriptResourceHandlerSection,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" requirePermission="false"
allowDefinition="MachineToApplication" />
<sectionGroup name="webServices"
type="System.Web.Configuration.ScriptingWebServicesSectionGroup,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35">
<section name="jsonSerialization"
type="System.Web.Configuration.ScriptingJsonSerializationSection,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" requirePermission="false"
allowDefinition="Everywhere" />
<section name="profileService"
type="System.Web.Configuration.ScriptingProfileServiceSection,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" requirePermission="false"
allowDefinition="MachineToApplication" />
<section name="authenticationService"
type="System.Web.Configuration.ScriptingAuthenticationServiceSection,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" requirePermission="false"
allowDefinition="MachineToApplication" />
<section name="roleService"
type="System.Web.Configuration.ScriptingRoleServiceSection,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" requirePermission="false"
allowDefinition="MachineToApplication" />
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
步驟2(IIS的所有版本)
的ASP.NET 4子Web應用程序是在IIS 6或IIS 7運行該步驟是必需的(或IIS 7.5)。
在運行ASP.NET 2或ASP.NET 3.5的父Web應用程序的Web.config文件中,添加一個位置標記,該標記明確指定(對於IIS和ASP.NET配置系統)配置條目僅適用於父級Web應用程序。下面的示例示出了位置元件的語法添加:
<location path="" inheritInChildApplications="false" >
下面的示例示出了位置標籤如何用於包裹開始appSettings部分,並與系統結束所有構成部分。 webServer部分。
<location path="" inheritInChildApplications="false" >
當您完成步驟1和2,兒童ASP.NET 4 Web應用程序將啓動沒有錯誤。
這就是IIS的配置工作原理;每個級別都從它上面的級別繼承。這應該給你一個暗示,你是否可以*做你正在做的事情...... – 2012-01-16 12:18:05
你能告訴我如何部署這個應用程序嗎?我需要創建一個新的網站嗎? – user960567 2012-01-16 12:23:18
我剛剛找到inheritInChildApplications。檢查此 – user960567 2012-01-16 12:33:12