Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/302.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
C# 跨应用程序复制HttpContext用户名_C#_Asp.net Mvc_Iis_Httpcontext_Authentication - Fatal编程技术网

C# 跨应用程序复制HttpContext用户名

C# 跨应用程序复制HttpContext用户名,c#,asp.net-mvc,iis,httpcontext,authentication,C#,Asp.net Mvc,Iis,Httpcontext,Authentication,所以我有个问题。我有自己的CustomMembership类,我在几乎所有的MVC应用程序中都使用它,这个自定义类继承了“MembershipProvider” 每个应用程序都有自己的用户数据库,因此用户信息很少在各个应用程序中复制,除非每个应用程序中都有帐户。无论如何,自从部署它们以来,我越来越意识到HttpContext正在通过IIS跨这些应用程序进行复制。我有两个主要问题: 有人将以“user1”身份登录,但HttpContext正在返回“user3”的用户名 来自一个应用程序的用户上下文

所以我有个问题。我有自己的CustomMembership类,我在几乎所有的MVC应用程序中都使用它,这个自定义类继承了“MembershipProvider”

每个应用程序都有自己的用户数据库,因此用户信息很少在各个应用程序中复制,除非每个应用程序中都有帐户。无论如何,自从部署它们以来,我越来越意识到HttpContext正在通过IIS跨这些应用程序进行复制。我有两个主要问题:

有人将以“user1”身份登录,但HttpContext正在返回“user3”的用户名 来自一个应用程序的用户上下文将位于缓存或会话中,或者其他任何位置,然后显示在另一个应用程序中。我正要测试一个应用程序,它在获取用户角色时给了我一个异常,因为它搜索的用户名在此应用程序中不存在,而是另一个,并且由于某种原因被吹捧为当前上下文。 这是令人困惑的,我想知道我是否遗漏了什么或者初始化失败了什么。下面是我的web配置用户身份验证部分的副本

<authentication mode="Forms">
  <forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>
<membership defaultProvider="CustomMembershipProvider">
  <providers>
    <clear />
    <add name="CustomMembershipProvider" type="HRUpdate.App_Data.CustomMembershipProvider" connectionStringName="HRpimEntities" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
    <!--<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" applicationName="/"/>-->
  </providers>
</membership>
<roleManager defaultProvider="MyRoleProvider" enabled="true" cacheRolesInCookie="true">
  <providers>
    <clear />
    <add name="MyRoleProvider" type="HRUpdate.App_Data.MyRoleProvider" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" writeExceptionsToEventLog="false" />
  </providers>
</roleManager>

您的CustomMembership类是一个静态类,具有静态用户名成员吗?没有静态类。我的成员身份类定义如下:公共类CustomMembershipProvider:MembershipProvider{…}