1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / multiple providers

multiple providers

2 posts, 0 answered
  1. Aaron
    Aaron avatar
    39 posts
    Registered:
    16 Apr 2009
    03 Jun 2009
    Link to this post
    Having trouble getting this to work like I want.  My issue is the following code works for my custom provider (logging in front side) but how can I get this code to work from cms provider (logging in back end) at the same time.

            Dim User As MembershipUser = Membership.GetUser() 
     
            If User.IsApproved() = False Then 
                ' 
                  ' 
                       ' 
            End If 
     

    Currently I'm getting this error when trying to view page from back end.

    Object reference not set to an instance of an object.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:

    Line 25: 
    Line 26: 
    Line 27:         If User.IsApproved() = False Then
    Line 28:             'Response.Redirect("loginName.aspx?ReturnURL=" + HttpContext.Current.Request.Url.ToString())
    Line 29:         End If

    Source File: F:\KYPartnership_EARS_SF\UserControls\EARS\Users.ascx.vb    Line: 27

    Stack Trace:

    [NullReferenceException: Object reference not set to an instance of an object.]
       EarsWUC_Admin_office_Users.Page_Load(Object sender, EventArgs e) in F:\KYPartnership_EARS_SF\UserControls\EARS\Users.ascx.vb:27
       System.Web.UI.Control.OnLoad(EventArgs e) +99
       System.Web.UI.Control.LoadRecursive() +50
       System.Web.UI.Control.AddedControl(Control control, Int32 index) +265
       System.Web.UI.ControlCollection.Add(Control child) +80
       Telerik.Cms.Web.PreviewPage.CreateChildControls() +1329
       System.Web.UI.Control.EnsureChildControls() +87
       System.Web.UI.Control.PreRenderRecursiveInternal() +44
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842
    


    Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082


    I'm running sitefinity 3.6 sp2.

    Here is my web.config provider setup:
            <roleManager enabled="true" cacheRolesInCookie="true" defaultProvider="SqlProvider"
                <providers> 
                    <clear/> 
                    <add connectionStringName="xConnectionString" applicationName="/xap" name="SqlProvider" type="System.Web.Security.SqlRoleProvider"/> 
                    <add connectionStringName="DefaultConnection" applicationName="/" name="Sitefinity" type="Telerik.DataAccess.AspnetProviders.TelerikRoleProvider, Telerik.DataAccess"/> 
                </providers> 
            </roleManager> 
            <membership defaultProvider="SqlProvider"
                <providers> 
                    <clear/> 
                    <add name="Sitefinity" connectionStringName="DefaultConnection" type="Telerik.DataAccess.AspnetProviders.TelerikMembershipProvider, Telerik.DataAccess" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" passwordAttemptWindow="10" passwordStrengthRegularExpression="" minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0"/> 
                    <add connectionStringName="xConnectionString" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" applicationName="/xap" name="SqlProvider" type="System.Web.Security.SqlMembershipProvider"/> 
                </providers> 
            </membership> 
            <profile defaultProvider="SqlProvider"
                <providers> 
                    <clear/> 
                    <add name="Sitefinity" connectionStringName="DefaultConnection" applicationName="/" type="Telerik.DataAccess.AspnetProviders.TelerikProfileProvider, Telerik.DataAccess"/> 
                    <add name="SqlProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="xConnectionString" applicationName="/xap"/> 
                </providers> 
                <properties> 
                    <add name="FirstName"/> 
                    <add name="LastName"/> 
                    <add name="Office"/> 
                    <add name="District"/> 
                    <group name="Address"
                        <add name="Street1"/> 
                        <add name="Street2"/> 
                        <add name="City"/> 
                        <add name="State"/> 
                        <add name="Zip"/> 
                    </group> 
                    <add name="Phone"/> 
                    <add name="PhoneExt"/> 
                    <add name="Fax"/> 
                    <add name="Email"/> 
                    <add name="AssessmentQuestions"/> 
                </properties> 
            </profile> 
     

    My login for front end is as follows:
    using System; 
    using System.Web.UI; 
    using System.Web.UI.WebControls; 
    using System.Web; 
    using Telerik.Security; 
    using System.Web.Security; 
     
    public partial class UserControls_FinalLoginControls_LoginControl : UserControl 
        void Page_Load(object sender, EventArgs e) 
        { 
            this.Login1.LoggedIn += new EventHandler(Login1_LoggedIn); 
        } 
     
        void Login1_LoggedIn(object sender, EventArgs e) 
        { 
            HttpCookie cookie = this.Response.Cookies[FormsAuthentication.FormsCookieName]; 
     
            if (!String.IsNullOrEmpty(Login1.MembershipProvider)) 
            { 
                UserManager man = new UserManager(Login1.MembershipProvider); 
                man.SetAuthenticationCookie(cookie); 
            } 
            else 
                UserManager.Default.SetAuthenticationCookie(cookie); 
     
            string redirectUrl = Request.QueryString["ReturnUrl"]; 
     
            if (string.IsNullOrEmpty(redirectUrl)) 
            { 
                redirectUrl = this.Login1.DestinationPageUrl; 
            } 
            else 
            { 
                redirectUrl = HttpUtility.UrlDecode(redirectUrl); 
            } 
     
            this.Page.Response.Redirect(redirectUrl, true); 
        } 
     
     
     
        public Login Login 
        { 
            get 
            { 
                return this.Login1; 
            } 
            set 
            { 
                this.Login1 = value; 
            } 
        } 
     
     

  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    08 Jun 2009
    Link to this post
    Hello Aaron,

    Well, it seems that the User object is for some reason null.
    Could you please describe the whole case in details, and send us the user controls you use for logging?

    All the best,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
2 posts, 0 answered