我正在一个有内部和外部部分的网站上工作。
这两个部分的用户不同,因此他们需要不同的登录页面。我想为这两个文件夹配置不同的身份验证,但是 ASP.Net 但不允许这样做。
示例(在我的主 web.config 中):
<authentication mode="Forms">
<forms loginUrl="~/Pages/Internal/Main.aspx" defaultUrl="~/Pages/Internal/Main.aspx" cookieless="UseDeviceProfile" name=".ApplicationAuthenticatedUser" path="/" protection="All" slidingExpiration="true" timeout="45"/>
</authentication>
在外部子文件夹中,我尝试覆盖设置:
<authentication mode="Forms">
<forms loginUrl="~/Pages/External/Default.aspx" defaultUrl="~/Pages/External/Default.aspx" cookieless="UseDeviceProfile" name=".ApplicationAuthenticatedUser" path="/Pages/External" protection="All" slidingExpiration="true" timeout="45"/>
</authentication>
然而,这给了我一个错误。
我尝试将它们都放在它们的子文件夹中,但我得到了同样的错误,身份验证配置部分必须在应用程序级别设置(我猜这意味着根 web.config)。
一种可能的解决方案是集中登录页面并根据请求的来源进行重定向,如果它来自外部页面,则将其发送到外部登录页面,否则发送到内部页面。
它会起作用,但如果可能的话,我想要可以在 web.config 中配置它的解决方案。
谢谢