Copied to clipboard

Flag this post as spam?

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


  • Elad Lachmi 112 posts 144 karma points
    Jul 21, 2011 @ 05:22
    Elad Lachmi
    0

    Membership DB access from backend section

    Hi,

    I'm working on a new section for the backend and I have a small issue.

    In a grid (jqGrid) I want to diplay some data. I get the data via linq and I want to get the email from the membership provider (the membership table itself is in another DB).

    I use the following code:

     

     

     

     

     

     

    PaymentsDataContext data = new PaymentsDataContext();

     

    var q = from act in data.activations

     

    where act.approved != true

     

    orderby act.activationDate ascending

     

    select new {activationID = act.activationID, userName = act.userName,

    brokerName = act.broker.brokerName, existingAccount = act.existingAccount,

    activationDate = act.activationDate, brokerUser = act.brokerUser, approved = act.approved,

    email = System.Web.Security.

     

    Membership.GetUser(act.userName).Email};

    When I run this code I get a NullReferenceException. I should be able to access the membership provider from the backend, right?

    Any one see what I'm missing?

    Thank you!

  • Dirk De Grave 4537 posts 6006 karma points MVP 3x admin c-trib
    Jul 21, 2011 @ 10:17
    Dirk De Grave
    1

    Can't see anything wrong right now, but a good test would be to check whether GetUser() is working as expected... So, don't pass act.userName but start with a userName you know it's in the db and find out whether it's returning some info. If it doesn't, than you know it's a problem on the Membership side of things, otherwise it'll be your code which is not correct.

     

    Cheers,

    /Dirk

  • Elad Lachmi 112 posts 144 karma points
    Jul 28, 2011 @ 09:35
    Elad Lachmi
    0

    Well... turns out that I should have check that there even was a logged in user before searching for their username :)

    That was the issue, not the code I posted.

    Silly me... Sorry.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies