草庐IT

CURRENT_USER

全部标签

c# - User.Identity.GetUserId() 登录成功后返回null

我定义了一个临时变量来获取当前用户ID,它总是返回null。这是截图:为什么?更新:////POST:/Account/Login[HttpPost][AllowAnonymous]publicasyncTaskLogin(LoginViewModelmodel,stringreturnUrl){if(!ModelState.IsValid){returnJson(new{success=false,ex="Failtologin."});}varresult=awaitSignInManager.PasswordSignInAsync(model.Email,model.Passwo

c# - 将 HttpContext.Current.User 与异步等待一起使用的正确方法

我正在使用异步操作并像这样使用HttpContext.Current.UserpublicclassUserService:IUserService{publicILocPrincipalCurrent{get{returnHttpContext.Current.UserasILocPrincipal;}}}publicclassChannelService:IDisposable{//IntheservicelayerpublicChannelService():this(newEntities.LocDbContext(),newUserService()){}publicChan

c# - 将 HttpContext.Current.User 与异步等待一起使用的正确方法

我正在使用异步操作并像这样使用HttpContext.Current.UserpublicclassUserService:IUserService{publicILocPrincipalCurrent{get{returnHttpContext.Current.UserasILocPrincipal;}}}publicclassChannelService:IDisposable{//IntheservicelayerpublicChannelService():this(newEntities.LocDbContext(),newUserService()){}publicChan

c# - HttpContext.Current.Cache.Insert 和 HttpContext.Current.Cache.Add 有什么区别

我正在开发一个ASP.NETweb应用程序,我想实现缓存,所以我想知道HttpContext.Current.Cache.Insert和HttpContext.Current之间的区别.Cache.Add哪个更好? 最佳答案 两者之间的主要区别在于,如果缓存中已存在同名对象,则对Cache实例调用的Insert方法将替换对象,而Add方法调用将失败(取自Add和Insert方法在其各自的MSDN引用页上的Remarks段落):添加Callstothismethodwillfailifanitemwiththesamekeyparam

c# - HttpContext.Current.Cache.Insert 和 HttpContext.Current.Cache.Add 有什么区别

我正在开发一个ASP.NETweb应用程序,我想实现缓存,所以我想知道HttpContext.Current.Cache.Insert和HttpContext.Current之间的区别.Cache.Add哪个更好? 最佳答案 两者之间的主要区别在于,如果缓存中已存在同名对象,则对Cache实例调用的Insert方法将替换对象,而Add方法调用将失败(取自Add和Insert方法在其各自的MSDN引用页上的Remarks段落):添加Callstothismethodwillfailifanitemwiththesamekeyparam

《项目实战》构建SpringCloud alibaba项目(三、构建服务方子工程store-user-service)

系列文章目录构建SpringCloudalibaba项目(一、构建父工程、公共库、网关)构建SpringCloudalibaba项目(二、构建微服务鉴权子工程store-authority-service)构建SpringCloudalibaba项目(三、构建服务方子工程store-user-service)文章目录系列文章目录前言1、微服务子工程store-user-service1.1、创建子工程store-user-service1.2、修改pom.xml配置1.3、修改application.yml配置1.4、配置plus分页1.4.1、添加依赖1.4.2、添加配置1.5、配置naco

c# - 单元测试 HttpContext.Current.Cache 或 C# 中的其他服务器端方法?

为使用HttpContext.Current.Cacheclass的类创建单元测试时,我在使用NUnit时出错。功能是基本的-检查一个项目是否在缓存中,如果不在,则创建它并将其放入:if(HttpContext.Current.Cache["Some_Key"]==null){myObject=newObject();HttpContext.Current.Cache.Insert("Some_Key",myObject);}else{myObject=HttpContext.Current.Cache.Get("Some_Key");}从单元测试中调用它时,遇到第一个Cache行时会

c# - 单元测试 HttpContext.Current.Cache 或 C# 中的其他服务器端方法?

为使用HttpContext.Current.Cacheclass的类创建单元测试时,我在使用NUnit时出错。功能是基本的-检查一个项目是否在缓存中,如果不在,则创建它并将其放入:if(HttpContext.Current.Cache["Some_Key"]==null){myObject=newObject();HttpContext.Current.Cache.Insert("Some_Key",myObject);}else{myObject=HttpContext.Current.Cache.Get("Some_Key");}从单元测试中调用它时,遇到第一个Cache行时会

c# - HttpContext.Current 未在 MVC 4 项目中解析

我想使用ImageResizer(来自ImageResizingdotnet)。我通过NuGet为MVC安装了ImageResizer。但是当我去使用示例中的以下代码时://Loopthrougheachuploadedfileforeach(stringfileKeyinHttpContext.Current.Request.Files.Keys){HttpPostedFilefile=HttpContext.Current.Request.Files[fileKey];if(file.ContentLengthand,or//evenasantiziedversionoftheor

c# - HttpContext.Current 未在 MVC 4 项目中解析

我想使用ImageResizer(来自ImageResizingdotnet)。我通过NuGet为MVC安装了ImageResizer。但是当我去使用示例中的以下代码时://Loopthrougheachuploadedfileforeach(stringfileKeyinHttpContext.Current.Request.Files.Keys){HttpPostedFilefile=HttpContext.Current.Request.Files[fileKey];if(file.ContentLengthand,or//evenasantiziedversionoftheor