web.config 中的 <authorization> 标记导致调试模式出现问题
<authorization> tag in web.config causing problems in debug mode
我有一个 ASP.net Visual Studio 项目并且在网络配置中有以下内容:
<authorization>
<allow roles = "Domain\UserGroup" />
<deny users="*" />
</authorization>
这意味着只有“Domain\UserGroup”中的用户才能访问该页面。
当页面发布到 IIS 时,这工作正常,但是当我在我的本地 Visual Studio 和 运行 使用 F5 的项目上工作时,我得到
Server Error in '/' Application.
Access is denied.
Description: An error occurred while accessing the resources required to serve this request. The server may not be configured for access to the requested URL.
如果我把这个部分拿出来,它 运行 在本地没问题。
除了在 Web 配置中注释掉该部分并在发布到 IIS 时恢复它之外,还有其他解决方法吗?
感谢 ADyson 的提醒。事实上,我需要查看 web.config 转换。
在我的 Web.Release.config 我添加了
<authorization xdt:Transform="Insert">
<allow roles = "Domain\UserGroup" />
<deny users="*" />
</authorization>
在 system.web 部分并将其从我的主要 Web.config 中删除。
我还需要更改构建配置以在调试模式下发布(因此未对 web.config 文件进行任何更改)
我有一个 ASP.net Visual Studio 项目并且在网络配置中有以下内容:
<authorization>
<allow roles = "Domain\UserGroup" />
<deny users="*" />
</authorization>
这意味着只有“Domain\UserGroup”中的用户才能访问该页面。
当页面发布到 IIS 时,这工作正常,但是当我在我的本地 Visual Studio 和 运行 使用 F5 的项目上工作时,我得到
Server Error in '/' Application.
Access is denied.
Description: An error occurred while accessing the resources required to serve this request. The server may not be configured for access to the requested URL.
如果我把这个部分拿出来,它 运行 在本地没问题。
除了在 Web 配置中注释掉该部分并在发布到 IIS 时恢复它之外,还有其他解决方法吗?
感谢 ADyson 的提醒。事实上,我需要查看 web.config 转换。
在我的 Web.Release.config 我添加了
<authorization xdt:Transform="Insert">
<allow roles = "Domain\UserGroup" />
<deny users="*" />
</authorization>
在 system.web 部分并将其从我的主要 Web.config 中删除。
我还需要更改构建配置以在调试模式下发布(因此未对 web.config 文件进行任何更改)