Using iMIS 15.1.2.
I have a custom page that allows a user to register to become a member. It either creates a new contact, or uses their existing contact (if they remember their email address or have already logged in).
This custom page takes in a variety of information and saves it to the contact, as well as some user defined fields. It also creates a new subscription and bills the contact.
After all this is done, I attempt to redirect the user to the standard Dues Billing page, which is where my problems lie. Even though I've logged the user in via code, they still get redirected to the login page. (If they login here, it will then take them to the billing page, properly).
I want to avoid this second login. Am I missing something when authenticating a user through code?
The code in question, which happens just before the redirect, is as follows:
IiMISUser user = CContactUser.LoginByWebLogin(login);
user.ThrowExceptionOnError = true;
Session["LoginUser"] = user;
Response.Redirect("Billing/Core/AccountManagement/Billing.aspx");
Any help is greatly appreciated.
Thanks,
Colin
I think you need to set the
I think you need to set the authorisation cookies before you navigate to any other pages. Please try this code
using (Asi.Security.SecurityContext.ImpersonateAnonymous())
{
Asi.Security.SecurityContext.LogonByUserId(_username);
Session["LoginUser"] = Asi.iBO.ContactManagement.CContactUser.LoginByWebLogin(_username);
FormsAuthentication.SetAuthCookie(Asi.Security.AppPrincipal.CurrentIdentity.Name, false);
Response.Redirect("Billing/Core/AccountManagement/Billing.aspx");
}
Balaji