我在
asp.net v4.7.2 web app
中的 my.example.com
设置了 IIS
。它使用 asp.net Forms Authentication
。是Web.Config
:
<httpCookies requireSSL="true" />
<authentication mode="Forms">
<forms loginUrl="~/Default.aspx" defaultUrl="~/User/Default.aspx" slidingExpiration="true" timeout="30" requireSSL="true" />
</authentication>
<roleManager defaultProvider="SqlProvider" enabled="true">
<providers>
<clear />
<add name="SqlProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="MyConnectionString" applicationName="MyApp" />
</providers>
</roleManager>
<membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="30">
<providers>
<clear />
<add name="SqlProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="MyConnectionString" applicationName="MyApp" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" passwordFormat="Hashed" minRequiredPasswordLength="8" minRequiredNonalphanumericCharacters="1" maxInvalidPasswordAttempts="25" />
</providers>
</membership>
我有另一个
asp.net v4.7.2 web app
,通过IIS > Add Application
作为my.example.com/test
。它从父站点的 Forms Authentication
继承 web.config
,我可以通过以编程方式获取角色和用户列表来确认这一点。 但是当我使用User.Identity.IsAuthenticated
检查身份验证时,它总是错误的。是Web.config
:
<authentication>
<forms loginUrl="~/../Default.aspx">
</forms>
</authentication>
子站点只能看到
ASP.NET_SessionId
cookie,其值与父站点相同,但看不到 .ASPXAUTH
cookie(通过记录 cookie 进行检查)。我认为,如果它可以看到 Auth cookie,它应该能够验证并且 IsAuthenticated 应该变为 true。
如何在子应用程序中从父站点 https://my.example.com 读取身份验证 https://my.example.com/test