简体   繁体   中英

Is there a way to update HttpContext.Current.User.Identity.Name in an c# application using web.config file?

我正在使用具有匿名身份验证的ASP .Net应用程序,需要在web.config文件中设置HttpContext.Current.User.Identity.Name的值,因此需要为每个请求分配该值。

The HttpContext.Current.User object is for .Net Frameworks integrated authentication framework only (using Forms- or Windows-Authentication) and can not be set programmatically. If you need a value from the web.config in every request I would suggest to just read the value set in the web.config using

System.Configuration.ConfigurationManager.AppSettings[key]

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