Hi guys,
I have integrated YAF with my site: I can login and register via the YAF membership.
Here is the problem: I login on my main site and then navigate to mysite.com/forums and I am not logged into the forum. Then, when I log into the forum and go back to the main site, I am no longer logged into the main site.
I have this in my main site web.config:
<authentication mode="Forms">
<forms name=".YAFNET_Authentication" protection="All" timeout="43200" cookieless="UseCookies" loginUrl="~/Error/UnAuthorized" />
</authentication>
It seems that when logging into the forum, it overwrites the cookie... This could all be circumvented if when logging into the main site and then going to the forum, the user is already logged into the forum (thus not needing to login again....)
Do any of you know how I can log the user into the forum when they sign in on the main site?
Here is my login code:
[HttpPost]
public ActionResult Login(YAF.Types.Models.User user)
{
var provider = new YafMembershipProvider();
var valueCollection = new NameValueCollection();
valueCollection.Add("connectionStringName", "yafnet");
valueCollection.Add("applicationName", "YetAnotherForum");
valueCollection.Add("passwordFormat", "Clear");
provider.Initialize("YafMembershipProvider", valueCollection);
if (provider.ValidateUser(user.DisplayName, user.Password))
{
const MembershipCreateStatus status = MembershipCreateStatus.Success;
var result = BaseClass.GetRegistrationResult(status);
FormsAuthentication.SetAuthCookie(user.DisplayName, false);
// return new JsonResult { Data = message };
}
return Redirect("../");
}
Thanks!