Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • doited 10 posts 28 karma points
    Jan 28, 2011 @ 15:45
    doited
    0

    usercontrols not working after upgrade

    Hi all,

    I'm currently trying to move our website from it's current (live) to another (backup) server and at the same time performing the long over due upgrade from 3.0.5 to 4.5.2

    After a couple of minor hiccups I've managed to get the site working except for some of the usercontrols which should be accessing the members section.  I keep getting

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

     

    The controls work fine on the 'live' server, but on the new server the controls don't seem to be able to access the umbraco.cms.businesslogic.member.Member object.

    I'm hoping that there is a quick / easy fix to this as I'd rather not have to rebuild the whole thing again.

    Any suggestions?

    Thanks

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 28, 2011 @ 16:53
    Jan Skovgaard
    0

    Hi doited

    Could you perhaps show some of the code form the user control that shows the exception? It's very likely that changes have happened to the API between those two versions so maybe code should be rewritten/refactored to make it work with the new version of Umbraco?

    /Jan

  • doited 10 posts 28 karma points
    Jan 28, 2011 @ 17:07
    doited
    0

    Hi Jan

    The problem happens during the load event below:

    using umbraco;
    using umbraco.BusinessLogic;
    using umbraco.cms.businesslogic;
    using umbraco.cms.businesslogic.member;
    using umbraco.cms.businesslogic.propertytype;
    using umbraco.interfaces;

    ..........

    protected void Page_Load(object sender, EventArgs e)
    {
               Member member = Member.GetCurrentMember();

               memberName = member.Text;
               memberEmail = member.Email;

    Label lblUser = (Label)this.FindControl("lblUser");
    lblUser.Text = lblUser.Text.Replace("%%NAME%%", member.Text);
    lblUser.Visible = true;
    }

     

    I've narrowed it down to the 'Member member = Member.GetCurrentMember();' line.

    Thanks again

  • Jason Prothero 422 posts 1243 karma points MVP c-trib
    Jan 28, 2011 @ 22:25
    Jason Prothero
    1

    Are you sure they are logged in?  If there is no CurrentMember, it could return NULL.

  • doited 10 posts 28 karma points
    Jan 30, 2011 @ 18:40
    doited
    0

    hi jason,

    i realise that could produce the error, but it cannot access the CurrentMember even if they are logged in. 

  • kristian schneider 190 posts 351 karma points
    Jan 30, 2011 @ 19:27
    kristian schneider
    0

    Could it be something with the membership provider?

    Check your web.config for that. My section looks like this:

        <membership defaultProvider="UmbracoMembershipProvider" userIsOnlineTimeWindow="15">
    <providers>
    <clear />
    <add name="UmbracoMembershipProvider" type="umbraco.providers.members.UmbracoMembershipProvider" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" defaultMemberTypeAlias="Profile" passwordFormat="Hashed" />
    <add name="UsersMembershipProvider" type="umbraco.providers.UsersMembershipProvider" enablePasswordRetrieval="false" enablePasswordReset="false" requiresQuestionAndAnswer="false" passwordFormat="Hashed" />
    </providers>
    </membership>

     

  • doited 10 posts 28 karma points
    Jan 31, 2011 @ 10:44
    doited
    0

    Sorry, I've made a bit of a mistake. 

    When I replied to Jasons post, i said that it couldn't access the current member when they are logged in.  I was wrong.

    When a user logs in, the login page returns the username to them that seems to be working.

    However, when the user tries to access the 'edit account' section I get a different error:

    Server Error in '/' Application.

    Unable to cast object of type 'ASP.default_aspx' to type 'umbraco.BasePages.UmbracoEnsuredPage'.



    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.InvalidCastException: Unable to cast object of type 'ASP.default_aspx' to type 'umbraco.BasePages.UmbracoEnsuredPage'.

    Source Error:
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:
    [InvalidCastException: Unable to cast object of type 'ASP.default_aspx' to type 'umbraco.BasePages.UmbracoEnsuredPage'.]
    umbraco.controls.ContentControl.CreateChildControls() +331
    System.Web.UI.Control.EnsureChildControls() +87
    umbraco.controls.ContentControl.OnInit(EventArgs e) +92
    System.Web.UI.Control.InitRecursive(Control namingContainer) +333
    System.Web.UI.Control.AddedControl(Control control, Int32 index) +198
    System.Web.UI.ControlCollection.Add(Control child) +80

    ....................

     

    I guess there is something I'm missing (Thank you captain obvious!)

    Again, thanks for any suggestions you can give me.

  • kristian schneider 190 posts 351 karma points
    Jan 31, 2011 @ 12:22
    kristian schneider
    0

    have you changed anything in the default.aspx file that comes with umbraco?

  • doited 10 posts 28 karma points
    Jan 31, 2011 @ 12:34
    doited
    0

    No.

    I have only edited the web.config and dashboard.config files.  Everything else was either copied from the live server, or from the upgrade zip file.

    I made sure that I ran the upgrade after I copied everything else across, so I wouldn't accidentaly overwrite a new dll with an old one.

    I bet there is some form of setting that I have missed / forgotten / didn't know about.

     

    But as it is only one page that is bringing up this error, I can't imagine what it can be.  Going to try and rebuild the usercontrol, but if another idea presents itself I would feel alot better...

     

Please Sign in or register to post replies

Write your reply to:

Draft