开发者

Form Authentication issue for two sub folders

开发者 https://www.devze.com 2023-02-05 02:59 出处:网络
In my application there are two sub folders which needs to be authenticated. In my application web.config, i have given like this

In my application there are two sub folders which needs to be authenticated. In my application web.config, i have given like this

  <authentication mode="Forms">
        <forms loginUrl="Customer/My Accounts/Default.aspx开发者_运维知识库"  name="formsauth1" 
             />
  </authentication>

This will work for only one sub folder having the path Customer/My Accounts/Default.aspx but I need to authenticate another sub folder having path Arab/Customer/My Accounts/Default.aspx. I want to know how to identify both the folders and how to authenticate them by modifying the above said code


You want to set the loginUrl equal to your login page, not the restricted page.

  <authentication mode="Forms">
        <forms loginUrl="Login.aspx"  name="formsauth1" />
  </authentication>

Then in the sub folders you want to create a web.config in each with the following:

<configuration>
    <system.web>
        <authorization>
            <deny users="?" />
        </authorization>
    </system.web>
</configuration>

So what will happen is that when an unauthenticated user tries to access those sub folders, the <authorization> element will deny them and redirect them to the loginUrl. After they log in, they'll be returned to the original page they were trying to access.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号