Copied to clipboard

Flag this post as spam?

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


  • Erik Ernst 70 posts 90 karma points
    Apr 09, 2010 @ 09:02
    Erik Ernst
    0

    Strange error with "Object reference not set to an instance of an object."

    I have created my own user control with a simple login form using asp:Login. This form is inserted into my login page in the template. In all my pages I have a little xslt macro using <xsl:when test="umbraco.library:IsLoggedOn() = true()" to check if the member is logged in or not. If not then I show a link to my login page.

    When I'm clicking on the link, then my login page shows up correctly.

    But if I instead is entering the login page directly as http://dynamicsexperts.net/login.aspx then I'm getting this error:

     

    Object reference not set to an instance of an object. body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Lucida Console";font-size: .9em} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }

    Server Error in '/' Application.

    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:

    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:

    [NullReferenceException: Object reference not set to an instance of an object.]
       DxLogin.LoginPageBox.Page_Load(Object sender, EventArgs e) +174
       System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
       System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
       System.Web.UI.Control.OnLoad(EventArgs e) +99
       System.Web.UI.Control.LoadRecursive() +50
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
    



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

     

    I am not really sure what goes on here. Shouldn't it be the same? The only thing what I can think about is that it might be something with this code of my user control:

            public string GetURL;

            protected void Page_Load(object sender, EventArgs e)
            {

                if (Request.IsAuthenticated)
                {
                    Login1.Visible = false;
                    Literal1.Text = "You are already logged in!";
                }


                if (!IsPostBack)
                {
                    GetURL = Request.UrlReferrer.ToString();
                }

                Login1.DestinationPageUrl = GetURL;
            }

    I would be very happy if anyone can see what there is wrong, or at least help me in the right direction.

  • Erik Ernst 70 posts 90 karma points
    Apr 20, 2010 @ 07:02
    Erik Ernst
    0

    Bump! Nobody who got an idea what can be wrong?

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Apr 20, 2010 @ 08:28
    Richard Soeteman
    0

    Hi Erik,

    If you access the page directly you don't have a referer, so this line (Request.UrlReferrer.ToString(); ) will not work. Make sure the Request.UrlReferer is not null.

    Cheers,

    Richard

Please Sign in or register to post replies

Write your reply to:

Draft