Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Fortunately, ASP.NET was built with this exact kind of scenario in mind.</p> <p>A quick example here would be the following project structure:</p> <ul> <li>LoginPage.aspx</li> <li>Default.aspx</li> <li>web.config</li> <li>/Protected <ul> <li>MembersOnlyPage.aspx</li> <li>web.config</li> </ul></li> </ul> <p>If I have understood you correctly, you can simply drop a 'web.config' file into the 'Protected' folder shown above. That web.config file should look like:</p> <pre><code>&lt;system.web&gt; &lt;authorization&gt; &lt;allow users ="Bob, Jane, Mary" /&gt; &lt;/authorization&gt; &lt;/system.web&gt; </code></pre> <p>Read up on the <strong><code>&lt;allow&gt;</code></strong> and <strong><code>&lt;deny&gt;</code></strong> elements of <strong><code>&lt;authorization&gt;</code></strong>, because you can also use the 'roles' attribute instead of 'users' to specify groups of users who should have access, or be denied access.</p> <p>You'll then need to modify the root web.config file to "turn on" forms authentication. Add something like:</p> <pre><code>&lt;authentication mode="Forms" &gt; &lt;forms loginUrl="LoginPage.aspx" name=".ASPNETAUTH" protection="All" path="~/" timeout="20"&gt; &lt;/forms&gt; &lt;/authentication&gt; </code></pre> <p>... to your <code>&lt;system.web&gt;</code> element.</p> <p>Now, all you have to do is wire up your LoginPage.aspx to log the user in. You can use the standard ASP.NET Login control for this purpose, and if you want to use your own database for authentication/authorisation, you can intercept the login control's events to do whatever you need to.</p> <p>For the quickest, most basic solution, check out the following video: </p> <p><a href="http://www.asp.net/learn/videos/video-45.aspx" rel="nofollow noreferrer">http://www.asp.net/learn/videos/video-45.aspx</a></p> <p>Hope this helps</p> <p>/Richard</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload