我正在主 Web 应用程序下的文件夹中运行 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 中的单独 Web 应用程序)
网络配置
<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/");
}