keep user logged in across subdomains asp.net -


for working on localhost in visual studio 2013.(i using individual user authentication)

what have done is:

i updated <system.web> in web.config as

<system.web>     <authentication mode="forms">         <forms loginurl="~/account/login" timeout="2880" name=".aspxauth" protection="validation" path="/" domain=".localhost" />     </authentication>     <machinekey validationkey="c50b3c89cb21f4f1422ff158a5b42d0e8db8cb5cda1742572a487d9401e3400267682b202b746511891c1baf47f8d25c07f6c39a104696db51f17c529ad3cabe" decryptionkey="8a9be8fd67af6979e7d20198cfea50dd3d3799c77af2b72f" validation="sha1" decryption="auto"/>     <compilation debug="true" targetframework="4.5" />     <httpruntime targetframework="4.5" /> </system.web> 

i updated startup.auth.cs as:

app.usecookieauthentication(new cookieauthenticationoptions {     authenticationtype = defaultauthenticationtypes.applicationcookie,     loginpath = new pathstring("/account/login"),     cookiedomain = ".localhost" }); 

but still login across sub-domains not maintained. else have make work?

you need share cookies across domains. code seems have set domain of cookie subdomain of localhost. issue in bindings in iis sub domains. check these 2 stackoverflow answers help.

share cookie between subdomain , domain

how make subdomain on localhost?

edit:

as told in comments cookies not being sent subdomain on request. haven't given expiry of cookie in code. give expiry setting valid timespan

    int days = 0, hours = 0, minutes = 0, seconds = 0;     app.usecookieauthentication(new microsoft.owin.security.cookies.cookieauthenticationoptions     {         authenticationtype = defaultauthenticationtypes.applicationcookie,         loginpath = new pathstring("/account/login"),         cookiedomain = ".localhost",         expiretimespan = new system.timespan(days, hours, minutes, seconds)     }); 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -