ASP.NET MVC成员身份-用户经常注销-不知道为什么 [英] ASP.NET MVC membership - user being logged out frequently - don't know why

查看:81
本文介绍了ASP.NET MVC成员身份-用户经常注销-不知道为什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.NET MVC 4 Web应用程序.在本地运行,它可以正常工作,但是在Web主机(使用共享主机)上,登录用户经常通过重定向回首页而注销.在大多数情况下,用户仅需执行少量操作即可注销.

I have an ASP.NET MVC 4 web application. Running locally, it works fine, but on the web host (which uses shared hosting), the logged on user is frequently logged out by being redirected back to the home page. In most cases, the user is logged out after performing only a few actions.

Web主机建议我的应用程序可能使用了过多的内存,但是我使用了一个程序来分析内存使用情况,并且我确认它没有使用过多的内存-实际上,该应用程序似乎只使用了一部分内存Web主机上分配的内存的数量.

The web host suggested that my application could be using up too much memory but I used a program to profile the memory usage and I confirmed that it wasn't using excessive amounts of memory - in fact the application seems to use a fraction of the allocated memory on the web host.

以下是使用的登录方法:

Here is the logon method that is used:

    public static Boolean Login(string Username, string Password, bool persistCookie  = false)
    {

        bool success = Membership.ValidateUser(Username, Password);
        if (success)
        {
            FormsAuthentication.SetAuthCookie(Username, persistCookie);
        }
        return success;
    }

在我的Web主机中,表单身份验证超时设置为60分钟,所以这不应该成为问题,对吧?

In my web host, the forms authentication timeout is set to 60 minutes, so that shouldn't be an issue, right?

<authentication mode="Forms">
  <forms loginUrl="~/Account/Login" timeout="60" />
</authentication>

并且我的会话状态超时值也设置为60分钟:

and my session state timeout value is also set to 60 minutes:

<sessionState mode="InProc" customProvider="DefaultSessionProvider" timeout="60">

根据答案此处,我还添加了此行,但似乎无法解决问题:

Based on the answer here, I added this line also, which didn't seem to solve the issue:

<machineKey validationKey="AutoGenerate,IsolateApps" decryptionKey="AutoGenerate,IsolateApps"></machineKey>

关于可能存在的问题以及我可以采取什么措施解决问题的任何想法?

Any ideas to what the problem might be and what I can do to solve the problem?

推荐答案

您的会话没有超时. IIS崩溃.由于您在内存会话中使用,因此每次IIS崩溃时,会话都将消失,用户将被注销.您应该检查服务器的事件视图,并查看错误的详细信息以找出错误的原因.

Your sessions are not timing out. The IIS is crashing. Since you are using in memory sessions, every time IIS crashes, your sessions are gone and the user gets logged out. You should check the server's event views and look into details of errors to find out what the error is.

这篇关于ASP.NET MVC成员身份-用户经常注销-不知道为什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆