Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.Net: How to allow access to a page to intranet user and deny for extranet users?

I have an app with two pages: pagein.aspx and pageout.aspx. Pagein.aspx must be accessible ONLY to intranet users of my company, but pageout.aspx must be accessible to extranet users (world). My last option is to use the authorization (user and password), but I prefer to use the logic I described. Is this possible in asp.net? If yes, how?

like image 906
stighy Avatar asked Nov 04 '11 14:11

stighy


People also ask

How to restrict Web page access in ASP net?

Control authorization by using file permissions To require authentication, remove the ASPNET user account's access permissions for the file or folder. To restrict access to specific Windows user accounts or group accounts, grant or deny Read NTFS file permissions to files or folders.


1 Answers

You can do this via web.config

<location path="Pagein.aspx"> 
    <system.web>
        <authorization>
          <allow users="*" allow role="YourDomain\Domain Users" />
          <deny users="*" />
         </authorization>
    </system.web>
</location>
<location path="PageOut.aspx"> 
    <system.web>
        <authorization>
          <allow users="*" />
        </authorization>
    </system.web>
</location>
like image 186
Ta01 Avatar answered Sep 28 '22 02:09

Ta01