I am having a problem with asp.net's membership

Discussion in 'ASP.NET 2.0' started by wdarnellg, Mar 25, 2007.

  1. I am having a problem with asp.net's membership. My local machine processes a login event perfectly; it checks to see if the user is in a particular role, and then sends them to the appropriate page. I have uploaded it to my hosted site and it gives me an 'object reference not set' error. I will post the error below. Please tell me what you think.
    First, here is the page's code they refer to:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim uInRole As String = Membership.GetUser.ToString
    If Roles.IsUserInRole(uInRole, "Client") = True Then
    Response.Redirect("Client/Home.aspx", True)
    ElseIf Roles.IsUserInRole(uInRole, "Parent") = True Then
    Response.Redirect("Parent/ParentSwitchbo<WBR>ard.aspx",<WBR> True)
    ElseIf Roles.IsUserInRole(uInRole, "Darnell") = True Then
    Response.Redirect("Darnell/Switchboard.a<WBR>spx", True)
    ElseIf Roles.IsUserInRole(uInRole, "ClientAndParent") = True Then
    Response.Redirect("ClientAndParent/Clien<WBR>tAndParent<WBR>Switchboar<WBR>d.aspx", True)
    End If
    End Sub

    And here is the error from the hosted server:

    Server Error in '/' Application.
    ----------------------------------------<WBR>----------<WBR>----------<WBR>----------<WBR>----------<WBR>
    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 7: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Line 8:
    Line 9: Dim uInRole As String = Membership.GetUser.ToString
    Line 10: If Roles.IsUserInRole(uInRole, "Client") = True Then
    Line 11: Response.Redirect("Client/Home.aspx", True)

    Source File: E:\web\dstroketen1\htdocs\Default.aspx.v<WBR>b Line: 9

    Stack Trace:

    [NullReferenceException: Object reference not set to an instance of an object.]
    _Default.Page_Load(Object sender, EventArgs e) in E:\web\dstroketen1\htdocs\Default.aspx.v<WBR>b:9
    System.Web.UI.Control.OnLoad(EventArgs e) +99
    System.Web.UI.Control.LoadRecursive() +47
    System.Web.UI.Page.ProcessRequestMain(Bo<WBR>olean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061






    Post Edited By Moderator (mjp) : 3/26/2007 5:50:07 PM GMT
     
  2. That may have had something to do with it. I did fix it though by enabling 'roles' in the 'roles management' element. Thanks for your reply.
     

Share This Page