locked
Membership class and exception handling RRS feed

  • Question

  • User-250275175 posted

    Hello, i have been reading a book (pro c# 2008 and . net 3.5 platform, Andrew Troelsen) and some site about c# development. In all this places they talk about the .Net way to handle exception and why we should use the .Net architecture to handle exception. 

    Usually they talk about how the old way of declaring constants representing the type of error and returning that in functions is wrong and should not be used.

    My problem is that checking the System.Web.Security.Membership class they implement some functions that return by reference using out parameters a MembershipCreateStatus (a enum) that represent the state of the executed function. 

    Now, isn't this a wrong approach? should not this class only implement exception handling and forget about enums for function states, or i am missing something here? 

    Thanks for your help!

    Tuesday, December 22, 2009 9:49 AM

All replies

  • User78336405 posted

    Hi,

    You could also refer:Beginning ASP.NET 3.5 in C# 2008: From Novice to Professional, Second Edition . There also have a good introduction to Membership.

    Thursday, December 24, 2009 1:50 AM
  • User-455638226 posted

    Exception should not be used as a replacement of parameter returning mechanism. For normal parameter pass in and out, you should use the "old" way. But for "abnormal" situations, for example, the network is not available, you use exception.

    I think, the implementation in System.Web.Security.Membership class is correct.


    Thanks,

    ------------------------------------

    Tim Robson
    My Free Email Marketing / Newsletter Software for You
    Comm100, Microsoft Gold Certified Partner

     

    Monday, January 4, 2010 10:22 PM