tags:

views:

47

answers:

1

Hi ,

how can I add default users in my web.config to test my asp: login control

Thanx

+1  A: 

I was wrong wrong wrong in my initial answer. You can set default users in Web.config if you do some simple authentication by yourself, but it doesn't seem to work when you are using the Login control.

I did some research, and it seems that, if you use the Login control, you can't set default users in Web.config and you have no way but setting a provider (as in a database) to store users credentials.

You can follow this tutorial from MSDN to configure what database to use:
Configuring an ASP.NET Application to Use Membership

The Web.config stuff:

<configuration>
  <connectionStrings>
    <add name="MySqlConnection" connectionString="Data 
      Source=MySqlServer;Initial Catalog=aspnetdb;Integrated
      Security=SSPI;" />
  </connectionStrings>
  <system.web>
    <authentication mode="Forms" >
      <forms loginUrl="login.aspx"
        name=".ASPXFORMSAUTH" />
    </authentication>
    <authorization>
      <deny users="?" />
    </authorization>
    <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15">
      <providers>
        <clear />
        <add 
          name="SqlProvider" 
          type="System.Web.Security.SqlMembershipProvider" 
          connectionStringName="MySqlConnection"
          applicationName="MyApplication"
          enablePasswordRetrieval="false"
          enablePasswordReset="true"
          requiresQuestionAndAnswer="true"
          requiresUniqueEmail="true"
          passwordFormat="Hashed" />
      </providers>
    </membership>
  </system.web>
</configuration>
Dan Dumitru
Thanx Dan for reply..i tried this but its not working..when login with login control :(
BreakHead
@Qutbuddin - Yes, sorry, I didn't have a chance to test it. It worked in one of my apps, but I was using some normal login code, and not the Login control. See my updated answer.
Dan Dumitru