Membership stuff acts wierd on production server

Discussion in 'ASP .Net' started by Bobby Edward, Oct 21, 2008.

  1. Bobby Edward

    Bobby Edward Guest

    My site is utilizing asp.net membership. It works perfect on the
    development machine.

    I copied the entire directory to the production server. Now it seems that
    the membership stuff is acting wierd.

    I can login ok. But it doesn't run the login redirect properly.

    Also, I wrote a simple test page that consists of this...
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles Me.Load
    response.write("DEBUG:")
    For Each role As String In Roles.GetAllRoles
    Response.Write(role & ";")
    Next

    If User.IsInRole("Administrator") Then
    Response.Write("admin/manageusers.aspx")
    ElseIf User.IsInRole("Engineer") Then
    Response.Write("engineer/manageprojects.aspx")
    ElseIf User.IsInRole("Non-Engineer") Then
    Response.Write("membersonly/mycivcast.aspx")
    Else
    Response.Write("default.aspx")
    End If
    End Sub

    On my local dev machine it spits out all the roles (from the For statement.)
    In the production server it doesn't spit out ANY roles, even though the
    web.config's both point to the production server mysql db.

    Any ideas? Thanks.
    Bobby Edward, Oct 21, 2008
    #1
    1. Advertising

  2. Bobby Edward

    Jason James Guest

    I have been recently developing with the membership provider and found
    this snippet of code very useful in determining if I was correctly
    authenticated as a user. This might give you some insight as to
    whether or not you are actuall authenticating correctly. I added it
    to my default page and got the login page to redirect me.

    FormsIdentity id = (FormsIdentity)User.Identity;
    FormsAuthenticationTicket ticket = id.Ticket;

    Response.Write("<p/>TicketName: " + ticket.Name);
    Response.Write("<br/>Cookie Path: " + ticket.CookiePath);
    Response.Write("<br/>Ticket Expiration: " +
    ticket.Expiration.ToString());
    Response.Write("<br/>Expired: " + ticket.Expired.ToString());
    Response.Write("<br/>Persistent: " +
    ticket.IsPersistent.ToString());
    Response.Write("<br/>IssueDate: " +
    ticket.IssueDate.ToString());
    Response.Write("<br/>UserData: " + ticket.UserData);
    Response.Write("<br/>Version: " + ticket.Version.ToString());

    Hope this is of some use.

    Jason.
    Jason James, Oct 21, 2008
    #2
    1. Advertising

  3. Bobby Edward

    Bobby Edward Guest

    Thanks Jason.

    I'm thinking this has to do with the fact that I am using custom
    membership/role providers (because I am using CoreLabs MyDirect.NET to
    access the MySQL database.)

    In my web.config I have it setup as this...

    <membership defaultProvider="AspNetMySqlMembershipProvider"
    userIsOnlineTimeWindow="15">
    <providers>
    <remove name="AspNetMySqlMembershipProvider" />
    <add name="AspNetMySqlMembershipProvider"
    type="CoreLab.MySql.Web.Providers.MySqlMembershipProvider"
    connectionStringName="MySqlServices" enablePasswordRetrieval="false"
    enablePasswordReset="true" requiresQuestionAndAnswer="true"
    requiresUniqueEmail="true" passwordFormat="Hashed"
    maxInvalidPasswordAttempts="5" passwordAttemptWindow="10"
    description="MyDirect membership provider" applicationName="/AmtekCivCast "
    minRequiredPasswordLength="5" minRequiredNonalphanumericCharacters="0" />
    <add name="PasswordResetProvider"
    type="CoreLab.MySql.Web.Providers.MySqlMembershipProvider"
    connectionStringName="MySqlServices" enablePasswordRetrieval="false"
    enablePasswordReset="true" requiresQuestionAndAnswer="false"
    requiresUniqueEmail="true" passwordFormat="Hashed"
    maxInvalidPasswordAttempts="5" passwordAttemptWindow="10"
    description="MyDirect membership provider" applicationName="/AmtekCivCast "
    minRequiredPasswordLength="5" minRequiredNonalphanumericCharacters="0" />
    </providers>
    </membership>
    <roleManager defaultProvider="AspNetMySqlRoleProvider" enabled="true"
    cacheRolesInCookie="true" cookieName=".ASPROLES" cookieTimeout="90"
    cookiePath="/" cookieProtection="All">
    <providers>
    <remove name="AspNetMySqlRoleProvider" />
    <add name="AspNetMySqlRoleProvider"
    type="CoreLab.MySql.Web.Providers.MySqlRoleProvider"
    connectionStringName="MySqlServices" />
    </providers>
    </roleManager>
    <!--<anonymousIdentification enabled="true"/>-->
    <profile defaultProvider="AspNetMySqlProfileProvider">
    <providers>
    <remove name="AspNetMySqlProfileProvider" />
    <add name="AspNetMySqlProfileProvider"
    type="CoreLab.MySql.Web.Providers.MySqlProfileProvider"
    connectionStringName="MySqlServices" />
    </providers>
    <properties>
    <!-- <add name="ZipCode" /> -->
    </properties>
    </profile>

    I'm thinking that I have to add these entries to the
    <system.data>/<DbProviderFactories> section, but I don't really know how
    yet.

    Sound right?

    Thanks!

    "Jason James" <> wrote in message
    news:...
    >I have been recently developing with the membership provider and found
    > this snippet of code very useful in determining if I was correctly
    > authenticated as a user. This might give you some insight as to
    > whether or not you are actuall authenticating correctly. I added it
    > to my default page and got the login page to redirect me.
    >
    > FormsIdentity id = (FormsIdentity)User.Identity;
    > FormsAuthenticationTicket ticket = id.Ticket;
    >
    > Response.Write("<p/>TicketName: " + ticket.Name);
    > Response.Write("<br/>Cookie Path: " + ticket.CookiePath);
    > Response.Write("<br/>Ticket Expiration: " +
    > ticket.Expiration.ToString());
    > Response.Write("<br/>Expired: " + ticket.Expired.ToString());
    > Response.Write("<br/>Persistent: " +
    > ticket.IsPersistent.ToString());
    > Response.Write("<br/>IssueDate: " +
    > ticket.IssueDate.ToString());
    > Response.Write("<br/>UserData: " + ticket.UserData);
    > Response.Write("<br/>Version: " + ticket.Version.ToString());
    >
    > Hope this is of some use.
    >
    > Jason.
    Bobby Edward, Oct 21, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Utku Altinkaya

    RPC Client acts like a server

    Utku Altinkaya, Jul 14, 2008, in forum: Python
    Replies:
    0
    Views:
    228
    Utku Altinkaya
    Jul 14, 2008
  2. Louis R.
    Replies:
    3
    Views:
    1,123
    Louis R.
    Dec 9, 2008
  3. Louis R.
    Replies:
    5
    Views:
    571
    Steven Cheng
    Jan 14, 2009
  4. microteq
    Replies:
    0
    Views:
    162
    microteq
    Jul 26, 2007
  5. David Westerink

    Wierd stuff in an controller

    David Westerink, Oct 5, 2009, in forum: Ruby
    Replies:
    1
    Views:
    95
    Rick DeNatale
    Oct 5, 2009
Loading...

Share This Page