【发布时间】:2013-01-08 03:07:54
【问题描述】:
我是ASP.NET 的新手,实际上我对此一无所知,但不要绝望,我不是在寻找教程...我的一个同事想要在我们的网络服务器上运行ASP.NET 应用程序。我们的网络服务器运行的是 Windows 2008 R2,带有 Plesk 11 和 IIS 7.5。
到目前为止,我在尝试启用 ASP.NET 时遇到了各种各样的问题,但经过一番折腾,我设法让应用程序正常工作(在一定程度上)。
但是,为了让应用程序正常工作,我不得不从我的 web.config 文件中删除以下行:
<configSections>
<sectionGroup name="system.webServer">
<sectionGroup name="rewrite">
<section name="rewriteMaps" overrideModeDefault="Allow" />
<section name="rules" overrideModeDefault="Allow" />
</sectionGroup>
</sectionGroup>
</configSections>
这是因为我收到了错误:
解析器错误消息:部分或组名称“system.webServer”是 已经定义了。对此的更新可能只发生在配置中 定义的级别。
我的文件夹结构是这样的:
website/
TestApplication/
web.config
index.php
web.config
我已经为文件夹“TestApplication”创建了一个应用程序(并不是说我真的知道这意味着什么),但这并没有任何区别。
我的印象是,如果您创建一个应用程序,目录中的web.config 将不会继承任何父配置!这似乎不会就是这种情况,因为我仍然收到错误。
我的问题是,对于上述情况,我该怎么办?如何阻止应用程序继承父目录配置,或者修复当前的web.config 文件以使用ASP.NET?
需要注意的是,我在 IIS 管理器和 Plesk 中都进行了更改,因为我无法在 Plesk 控制面板中找到特定的内容,例如:为网站中的目录创建应用程序。我认为这不是问题的原因,但是,值得一提。
更新
这是我的完整 web.config 文件(删除了我的所有规则之一,因为它们对文件没有影响):
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configSections>
<sectionGroup name="system.webServer">
<sectionGroup name="rewrite">
<section name="rewriteMaps" overrideModeDefault="Allow" />
<section name="rules" overrideModeDefault="Allow" />
</sectionGroup>
</sectionGroup>
</configSections>
<system.webServer>
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true"/>
<rewrite>
<rules>
<clear />
<rule name="Browser Error Rewrite" stopProcessing="true">
<match url="^errors/browser$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="_errors/browser.php?error=browser" />
</rule>
</rules>
</rewrite>
<defaultDocument>
<files>
<clear />
<add value="index.php" />
</files>
</defaultDocument>
<httpErrors>
<clear />
<error statusCode="400" prefixLanguageFilePath="" path="/_errors/error.php?id=400" responseMode="ExecuteURL" />
<error statusCode="502" prefixLanguageFilePath="" path="/_errors/error.php?id=502" responseMode="ExecuteURL" />
<error statusCode="407" prefixLanguageFilePath="" path="/_errors/error.php?id=407" responseMode="ExecuteURL" />
<error statusCode="414" prefixLanguageFilePath="" path="/_errors/error.php?id=414" responseMode="ExecuteURL" />
<error statusCode="415" prefixLanguageFilePath="" path="/_errors/error.php?id=415" responseMode="ExecuteURL" />
<error statusCode="501" prefixLanguageFilePath="" path="/_errors/error.php?id=501" responseMode="ExecuteURL" />
<error statusCode="500" prefixLanguageFilePath="" path="/_errors/error.php?id=500" responseMode="ExecuteURL" />
<error statusCode="401" prefixLanguageFilePath="" path="/_errors/error.php?id=401" responseMode="ExecuteURL" />
<error statusCode="403" prefixLanguageFilePath="" path="/_errors/error.php?id=403" responseMode="ExecuteURL" />
<error statusCode="404" prefixLanguageFilePath="" path="/_errors/error.php?id=404" responseMode="ExecuteURL" />
<error statusCode="405" prefixLanguageFilePath="" path="/_errors/error.php?id=405" responseMode="ExecuteURL" />
<error statusCode="412" prefixLanguageFilePath="" path="/_errors/error.php?id=412" responseMode="ExecuteURL" />
<error statusCode="406" prefixLanguageFilePath="" path="/_errors/error.php?id=406" responseMode="ExecuteURL" />
</httpErrors>
<handlers>
<clear />
<add name="PageHandlerFactory-Integrated" path="*.aspx" verb="GET,HEAD,POST,DEBUG" type="System.Web.UI.PageHandlerFactory" preCondition="integratedMode" />
<add name="php-5.3.10" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\Parallels\Plesk\Additional\PleskPHP53\php-cgi.exe" resourceType="Either" requireAccess="Script" />
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" />
</handlers>
</system.webServer>
</configuration>
【问题讨论】:
-
你尝试过 IIS url 重写模块吗? URL rewrite module
-
@RaviSilva 这就是创建这些
configSections块的原因,但无论如何感谢:-)。我已经整理好了,稍后会发布答案 -
@Ben Carey - 你是怎么解决的?
-
IIS URL 重写模块不会触及您的 web.config 并生成
configSections。如果是这样,那应该被认为是一个错误。您可以安全地将其从 web.config 文件中删除。
标签: asp.net iis web web-config plesk