文件上传时失去身份验证
Loosing authentication on file upload
当我上传文件(例如照片)时,我失去了用户会话,网站将我重定向到登录页面。
我在不同的文件夹中上传文件,而不是在项目的文件夹中。
Web.config, system.web:
<system.web>
<authentication mode="Forms">
<forms defaultUrl="/" loginUrl="/Account/Login" name="_User" timeout="60" path="/" />
</authentication>
<sessionState mode="InProc" timeout="60" />
<compilation targetFramework="4.7" />
<httpRuntime targetFramework="4.7" executionTimeout="3600" maxRequestLength="52428" />
<globalization culture="en-US" uiCulture="en-US" fileEncoding="utf-8" requestEncoding="utf-8" responseEncoding="utf-8" responseHeaderEncoding="utf-8" />
<customErrors mode="Off" defaultRedirect="/" redirectMode="ResponseRedirect" />
</system.web>
有什么想法吗?
始终在 cookies 和 form 中设置域,最好不使用 www.
,这样 cookie 可以即使用户或 url 没有包含它也能工作。
<httpCookies domain="domain.com" />
<forms domain="domain.com" />
这是可能的问题之一 - 其他可能是 requireSSL
字段。
当我上传文件(例如照片)时,我失去了用户会话,网站将我重定向到登录页面。 我在不同的文件夹中上传文件,而不是在项目的文件夹中。
Web.config, system.web:
<system.web>
<authentication mode="Forms">
<forms defaultUrl="/" loginUrl="/Account/Login" name="_User" timeout="60" path="/" />
</authentication>
<sessionState mode="InProc" timeout="60" />
<compilation targetFramework="4.7" />
<httpRuntime targetFramework="4.7" executionTimeout="3600" maxRequestLength="52428" />
<globalization culture="en-US" uiCulture="en-US" fileEncoding="utf-8" requestEncoding="utf-8" responseEncoding="utf-8" responseHeaderEncoding="utf-8" />
<customErrors mode="Off" defaultRedirect="/" redirectMode="ResponseRedirect" />
</system.web>
有什么想法吗?
始终在 cookies 和 form 中设置域,最好不使用 www.
,这样 cookie 可以即使用户或 url 没有包含它也能工作。
<httpCookies domain="domain.com" />
<forms domain="domain.com" />
这是可能的问题之一 - 其他可能是 requireSSL
字段。