3

我正在我的主 WebApplication 下的文件夹中运行最新版本的 YetAnotherForum。该子文件夹被配置为 IIS 中的应用程序,导航到该文件夹​​并登录非常有效。YAF 设置有成员资格提供程序并使用表单身份验证。

我现在要做的是让用户从主网站自动登录到论坛。主网站通过会话和 cookie 使用自定义身份验证。它不使用任何内置的 ASP.NET 身份验证或成员身份组件。

所以基本上我想要发生的是,当用户单击链接以访问论坛时,他们会被发送到一个处理页面,该页面在将它们发送到子文件夹之前将它们验证到 YAF 应用程序中。

即使主应用程序不使用内置的身份验证部分,我仍然将身份验证模式设置为表单,并确保其下方的标签与 YAF web.config 中的标签匹配。然后,在处理页面上,我调用 FormsAuthentication.SetAuthCookie(username, true),然后重定向。但无论如何,YAF 还是把我踢回了登录页面。不知道从这里去哪里。

主站点是:example.com/

网络配置:

<authentication mode="Forms">
  <forms name=".YAFNET_Authentication" protection="All" timeout="43200" cookieless="UseCookies" />
</authentication>

YAF 是:example.com/yaf(IIS 中的单独 WebApplication)

网络配置

<authentication mode="Forms">
  <forms name=".YAFNET_Authentication" protection="All" timeout="43200" cookieless="UseCookies" />
</authentication>

处理页面是:(伪)example.com/autoLogin.aspx.cs

public void AutLogin(){
    string userName = doStuffToGetUsername();
    YAFStuff.CreateUserIfNeeeded(userName);

    FormsAuthentication.SetAuthCookie(userName, true);
    Response.Redirect("/yaf/");
}
4

1 回答 1

0

我一直在搜索谷歌 2 天试图解决这个问题,但我终于偶然发现了解决方案。我需要一个在两个 web.config 文件上都匹配的 MachineKey 用于加密过程。

http://forum.yetanotherforum.net/yaf_postst8780_Custom-membership-and-role-provider-with-YAF-Profile-provider.aspx

甜的!

于 2010-02-02T16:24:15.133 回答