简体   繁体   中英

Anonymous authentication in mvc 5 project not working on production server

I am trying to authenticate Anonymously in my mvc 5 project, it seems to work fine in my local host, but after deploying to production server, it does not see see the anonymous authentication tag in web.config file, i am having this error: Object reference not set to instance of an object, meaning the Request.Anonymous field is null, i dont know how to get this work in mvc 5 e-commerce site on production, i will appreciate any help. Thanks.

Here is my code: I added this line of code to the config file inside system.web

<anonymousIdentification enabled="true" cookieless="UseCookies" cookieName=".ASPXANONYMOUS" cookieTimeout="4320" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" /> 

And this is how i reference it in my code behind:

var getRecord = (from u in db.ShoppingCarts.Where(x => x.CartSessionID.Equals(Request.AnonymousID)) select u).ToList();

You just have to change your authentication setting in IIS 附加的IIS映像

Enable Anonymous Authentication which will automatically change your web.config

Hopefully this will help you ..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM