Forms authentication on different hostings
Hi have form authenticaion for my site, and it works fine on localhost and godaddy, but after moving to another开发者_开发问答 hosting it stop working. After login in admin area after 2-3 minutes I redirecting back to login screen. Does anybody know if I change some settings on IIS or what is the source of the problem? My code looks like
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="10000" slidingExpiration="true"/>
</authentication>
FormsAuthentication.SetAuthCookie(userName, rememberMe);
If your application domain is being shut down and you have no machineKey section in Web.config (or validationKey/decryptionKey="AutoGenerate") you will get new validationKey/decriptionKey after every application start and authentication cookies will become invalid. Visit http://aspnetresources.com/tools/keycreator.aspx and add generated machineKey section into your Web.config.
精彩评论