Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 调用FormsAuthentication.SignOut()并重定向回页面后,Request.IsAuthenticated仍然为true_Asp.net_Asp.net Mvc 3_Firefox_Authentication_Urlrewriter.net - Fatal编程技术网

Asp.net 调用FormsAuthentication.SignOut()并重定向回页面后,Request.IsAuthenticated仍然为true

Asp.net 调用FormsAuthentication.SignOut()并重定向回页面后,Request.IsAuthenticated仍然为true,asp.net,asp.net-mvc-3,firefox,authentication,urlrewriter.net,Asp.net,Asp.net Mvc 3,Firefox,Authentication,Urlrewriter.net,当我的操作将用户注销并重定向回自身时,我发现页面没有正确重定向。返回重定向后,将再次调用该操作,但Request.IsAuthenticated仍然为true而不是false 我在代码中的每个FormsAuthentication.SetAuthCookie调用上都设置了断点,但没有一个断点被命中。我想验证没有代码会重新验证用户 public ActionResult MyAction() { if (Request.IsAuthenticated) { try {

当我的操作将用户注销并重定向回自身时,我发现页面没有正确重定向。返回重定向后,将再次调用该操作,但Request.IsAuthenticated仍然为true而不是false

我在代码中的每个FormsAuthentication.SetAuthCookie调用上都设置了断点,但没有一个断点被命中。我想验证没有代码会重新验证用户

public ActionResult MyAction() {
    if (Request.IsAuthenticated) {
        try {
            // Check some stuff put into the session when the user
            // is authenticated
        } catch {
            Session.Abandon();
            FormsAuthentication.SignOut();
            return Redirect("http://localhost/MyController/MyAction");
        }
    }
}
这完全可能是FireFox的问题,因为我使用的是FireFox 11.0,而且它似乎在Chrome中工作。有人知道为什么会这样吗

我还没有把它孤立到一个简单的项目中。我希望这是我错过的简单的东西

我还应该提到,我有一个UrlRewriter,它监视传入的请求,并可能将它们重定向到一个URL,该URL可能与主站点有一个单独的身份验证cookie。这可能是问题所在吗

更改:

// cookiePath: "/CustomPortal"
http://localhost/MyApp/SpecialRequestController/Render?appName=CustomPortal&pagePath=public/CustomPage
当用户通过MyApp身份验证时,cookiePath为/,但如果用户通过重写的URL身份验证,则cookiePath为/CustomPortal


谢谢你的帮助

您是否在web.config文件中定义了表单名称,这可能是原因之一

<authentication mode="Forms">
   <forms name="HCGAuth" timeout="60"></forms>
</authentication>

如果您在web.config文件中定义了表单名称,这可能是原因之一

<authentication mode="Forms">
   <forms name="HCGAuth" timeout="60"></forms>
</authentication>

我会检查当前的User.Identity.Name-它是否是windows帐户名?是同一个用户的会话刚刚过期吗?检查以确保set cookie标头下降以删除表单验证cookie。装载小提琴手,并在formsauth.SignOut上查看标题;好的,在请求的最后,我会在可能的时候尝试这个。不幸的是,我还没有弄明白如何始终如一地重现这一点。我怀疑这是FireFox的一个问题,因为它在Chrome中运行良好。FF似乎需要一段时间才能使cookie过期,因为在我写下问题并返回FF并重新加载页面后,cookie成功了。我会检查当前的User.Identity.Name-它是否是windows帐户名?是同一个用户的会话刚刚过期吗?检查以确保set cookie标头下降以删除表单验证cookie。装载小提琴手,并在formsauth.SignOut上查看标题;好的,在请求的最后,我会在可能的时候尝试这个。不幸的是,我还没有弄明白如何始终如一地重现这一点。我怀疑这是FireFox的一个问题,因为它在Chrome中运行良好。似乎FF需要一段时间才能使cookie过期,因为在我写下问题并返回FF并重新加载页面后,它起了作用。我没有这样做。我所做的是在调用SetAuthCookie时使用应用程序名作为cookie路径。有什么理由不能这样做吗?正如我所说,它在Chrome中工作,在FF中只会随机中断。我没有这样做。我所做的是在调用SetAuthCookie时使用应用程序名作为cookie路径。有什么理由不能这样做吗?正如我所说,它在Chrome中工作,在FF中只会随机中断。