Saturday, August 19, 2006

So I have mentioned before that LADotNet.org runs a Masters Series on Saturdays and this Saturday is no different. This week it is being presented by Ken Getz. Ken is a great presenter and we are glad to have him back in California (Sorry Florida). Anyway, as he was going through delegates and events and he covered something I was not aware of.

Anonymous Delegates. Whenever I used delegates in the past, I aways had a method that could be passed that would handle the call. You can also pass a proceedure or "Block of Code" instead of passing a pointer to a method like below. (Both C# and VB)

  184     static void AnonymousDelegate()

  185     {

  186       FileSearch4 fs =

  187         new FileSearch4("C:\\", FILESPEC, false);

  188       fs.Handler =

  189         delegate(FileInfo file)

  190         {

  191           Console.WriteLine("{0} ({1})",

  192             file.FullName, file.Attributes);

  193         };

  194       fs.Execute();

  195     }

 

I am not sure of a real use for this but it was interesting to see someting new.

 

Doc

posted on Saturday, August 19, 2006 10:12:53 PM (GMT Daylight Time, UTC+01:00)  #    Comments [1] Trackback
Sunday, July 09, 2006

Setting up membership for your ASP.Net website is pretty simple. All you need to do is:

  1.  run the scripts using the aspnet_regsql.ext tool (C:\WINDOWS\Microsoft.Net\Framework\v2.0.50727\aspnet_regsql.exe    your version number may be diferent) to set up the database tables.
  2. Add a membership section to your web.config. Making sure that you add the <clear/> tag since you need to override the machine.config.

       41     <membership>

       42       <providers>

       43         <clear/>

       44         <add name="AspNetSqlMembershipProvider"

       45                   type="System.Web.Security.SqlMembershipProvider,
                             System.Web, Version=2.0.0.0, Culture=neutral,
                             PublicKeyToken=b03f5f7f11d50a3a
    "

       46                   connectionStringName="LocalSqlServer"

       47                   enablePasswordRetrieval="false"

       48                   enablePasswordReset="true"

       49                   requiresQuestionAndAnswer="true"

       50                   applicationName="/"

       51                   requiresUniqueEmail="false"

       52                   minRequiredPasswordLength="1"

       53                   minRequiredNonalphanumericCharacters="0"

       54                   passwordFormat="Hashed"

       55                   maxInvalidPasswordAttempts="5"

       56                   passwordAttemptWindow="10"

       57                   passwordStrengthRegularExpression="" />

       58       </providers>

       59     </membership>

       60   </system.web>

  3. Add a connection string once again using the <clear/>  tag to clear out the machine.config settings. (I will tell you why soon) 

       16   <connectionStrings>

       17     <clear/>

       18     <add name="LocalSqlServer" connectionString="Data
                 Source=xxx;Initial Catalog=xxx;Persist Security
                 Info=True;User ID=xxxx; password=xxx
    " />

       19   </connectionStrings>


  4. Then load up the Web Site Administration Tool by going to Website\Asp.Net Configuration in VS2005.

  5. You will then be about to configure your membership using SQL2000/2005 using this tool.

So where is the gotcha you might ask?  Well, if you try to name your connection string anything other than LocalSqlServer, when you get to the provider tab you will see a message that says "No Provider Created".  This is why you need to clear out the connection string section using the  <clear/> tag so that you can override the setting in the machine.config.  

 

I hope that helps someone.

Happy Programming

 

Doc


posted on Sunday, July 09, 2006 11:10:27 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback