C# 如何仅对某些页面使用sso
我有一个web应用程序。在使用sso进行身份验证之前。我将下面显示的代码放在web.config页面中C# 如何仅对某些页面使用sso,c#,asp.net,single-sign-on,C#,Asp.net,Single Sign On,我有一个web应用程序。在使用sso进行身份验证之前。我将下面显示的代码放在web.config页面中 <authentication mode="Forms"> <forms loginUrl="https://sso.***.***.***/login" timeout="30" defaultUrl="~/Index.aspx" cookieless="UseCookies" slidingExpiration="true" path="/" />
<authentication mode="Forms">
<forms loginUrl="https://sso.***.***.***/login" timeout="30" defaultUrl="~/Index.aspx" cookieless="UseCookies" slidingExpiration="true" path="/" />
</authentication>
它工作得很好。每个人去那个网站都需要先登录。
现在我们需要改变,使一些网页向公众开放。所以人们不需要登录就可以访问某些页面,但某些页面仍然需要登录(使用sso)。
怎么做
谢谢使用web.config的
和
部分。如果当前要求用户登录所有页面,我假设您有以下情况:
<authorization>
<deny users="?">
</authorization>
您可以添加
元素(这些元素位于
部分之外):
您可以添加任意数量的
元素,还可以在path属性中以目录为目标
如果您想使目录的内容更整洁,可以将web.config添加到目录中,并将
和
元素添加到该web.config。页面底部有一个指向location元素的链接。嘿,Jason,你救了我一天!
<location path="publicpage.aspx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>