Folder protection with webconfig

Joined
Jul 20, 2010
Messages
1
Reaction score
0
Hi,

I am new to asp.net and I have subfolder in my rootfolder with files that needs to accessed by username and login from a loginpage. I have currently one default.aspx that I access this way in the root folder. This is a extract from my current webconfig file in the root folder:

Code:
<authentication mode="Forms">
      <forms name="appNameAuth" path="/" loginUrl="login.aspx" protection="All" timeout="30">
        <credentials passwordFormat="Clear">
          <user name="Member" password="xxx"/>
          
        </credentials>
      </forms>
    </authentication>
    <authorization>

      <deny users="?"/>

    </authorization>

But I want to move this page and have additional pages in a subfolder that are only accessed by the above mentioned credentials in my root webconfig file.

This is the function I am using on the Login.aspx page in my root folder:

Code:
Sub ProcessLogin(objSender As Object, objArgs As EventArgs)

  If FormsAuthentication.Authenticate(txtUser.Text, txtPassword.Text) Then
     FormsAuthentication.RedirectFromLoginPage(txtUser.Text, chkPersistLogin.Checked)
  Else
     ErrorMessage.InnerHtml = <font color="red">"<b>Nåt gick fel...</b>var vänlig och kontollera användarnamn samt lösenord..."</font>
  End If

All the pages in the subfolder will have the following code:

Code:
Sub Page_Load()
  'verify authentication
  If User.Identity.IsAuthenticated Then
    'display Credential information
            displayCredentials.InnerHtml = "&nbsp; You are logged in as: " & User.Identity.Name
               
            '<br>Authentication Used : <b>" & User.Identity.AuthenticationType & "</b>"
  Else
    'Display Error Message
    displayCredentials.InnerHtml = "Sorry, you have not been authenticated."
  End If
End Sub

    Protected Sub lnkLogut_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkLogut.Click
        
        'delete the users auth cookie and sign out
        FormsAuthentication.SignOut()
        'redirect the user to their referring page
        Response.Redirect(Request.UrlReferrer.ToString())
    End Sub

Every page in the root folder should be accessable by everyone, but only the pages in the subfolder should be accessed by login.

Thanks
Sohail
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top