腾讯云
开发者社区
文档
建议反馈
控制台
首页
学习
活动
专区
工具
TVP
最新优惠活动
文章/答案/技术大牛
搜索
搜索
关闭
发布
登录/注册
精选内容/技术社群/优惠产品,
尽在小程序
立即前往
文章
问答
(9999+)
视频
沙龙
1
回答
ActionFilterAttribute
Identity.Name
中
的
IHttpContextAccessor
为
空
authentication
、
identity
、
core
、
authorize
我在Api控制器上设置了一个AuthorizationFilter,在第一次调用时设置了用户身份,但在随后
的
api请求
中
访问httpContextAccessor时,User.Identity.Name
为
空
。我曾尝试使用注入,并将HttpContextAccessor设置
为
单例。, HttpContextAccessor>(); 控制器代码: private readonly
IHttpContextAccessor
_httpContextAccessor; TesControl
浏览 43
提问于2019-09-28
得票数 0
回答已采纳
2
回答
ASP.NET核心实体变更历史
asp.net-core
、
entity-framework-core
、
audit-logging
、
audit.net
我有很多这样
的
控制器:{ private readonly IEntityRepository _entity而且,由于该方法被标记为[Authorize],我需要记录它是由哪个用户编辑
的
。我在看Audit.NET,但我没有找到办法。
浏览 0
提问于2018-04-12
得票数 3
回答已采纳
3
回答
在ASP.NET Core3.0
中
获取当前认证用户用户名
的
方法是什么?
c#
、
asp.net-core
、
.net-core
、
asp.net-core-mvc
、
asp.net-core-3.0
我正在开发最新
的
ASP.NET Core3.0 Angular模板。我需要知道
的
是,我们如何在
ActionFilterAttribute
中
获得经过身份验证
的
用户和用户名。ClaimTypes.NameIdentifier返回当前
的
用户id,而ClaimTypes.Name返回
的
用户名为
空
。下面是我
的
代码:其中getUser
的
UserId
为
d15f997a-6f65-4eb2-aecb-8
浏览 36
提问于2019-10-20
得票数 7
回答已采纳
3
回答
IHttpContextAccessor
在类
中
为
空
c#
、
asp.net
、
asp.net-core-2.0
、
httpcontext
当我试图从类
中
的
IHttpContextAccessor
字段获取httpcontext时,我遇到问题。这就是我
的
startup.cs{public class UserContextService : IUserContextServices private readonly
IHttpContextAccessor
"
浏览 133
提问于2018-02-28
得票数 2
回答已采纳
1
回答
在.NET核心依赖项注入中使用与用户相关
的
参数配置服务
c#
、
dependency-injection
、
asp.net-core
、
.net-core
该服务需要API密钥,它从db加载,并且对每个用户都是唯一
的
。如何消除服务定位器模式,并通过用户在代码
中
动态配置服务密钥?什么是最佳做法?
浏览 0
提问于2021-07-14
得票数 1
回答已采纳
1
回答
从ASP.NET核心标识查看用户ID
的
应用程序
c#
、
asp.net-core
、
azure-application-insights
我想用User ID核心标识用户名填充应用程序
中
的
ASP.NET属性。我得到了微软
的
,但它适用于整个.NET框架。(
IHttpContextAccessor
httpContextAccessor) : base(httpContextAccessor) } }但我不知道该怎么把它包括在管道里。应用程序洞察仍然显示自己
的
用户ID。Configura
浏览 0
提问于2020-02-16
得票数 10
回答已采纳
1
回答
注入时IServiceCollection不包含任何元素
c#
、
asp.net-core
服务在asp.net核心web应用程序中注册,该应用程序引用包含标记助手
的
类库,因此它是两个单独
的
项目。我还必须将IServiceCollection注册
为
服务,因为它失败而没有(在尝试请求IRazorViewEngine时标记助手中缺少服务),但我认为集合是自动注册
的
。将一个集合添加到另一个相同类型
的
集合
中
似乎很奇怪。;} 类库,ViewResourceTagHelper.cs
浏览 2
提问于2017-10-05
得票数 0
回答已采纳
1
回答
无法访问HttpContextAccessor用户在OnActionExecuting上
的
声明
.net-core
、
jwt
我试图在我
的
自定义属性
中
访问来自HttpContextAccessor
的
用户声明。在这个应用程序
中
,我有一个UserService.cs (下面的代码),在这里我可以这样做。但是在我
的
自定义属性
中
的
OnActionExecuting上,声明是一个
空
错误。即使我从我
的
用户服务
中
调用函数,声明也不存在。 我
的
最终目标是获得用户
的
id,以检查用户是否具有管理权限。AttributeTar
浏览 3
提问于2021-01-09
得票数 0
回答已采纳
2
回答
如何为asp.net核心中
的
操作获取自定义属性名?
asp.net
、
asp.net-core
、
attributes
我已经
为
操作名称创建了一个属性。我想得到我服务
中
的
属性名。我尝试了这么多
的
解决方案,但什么也没回。这是我
的
属性类:{这是我使用该属性进行
的
操作: public IActionResult
浏览 3
提问于2021-03-10
得票数 1
回答已采纳
2
回答
ASP.NET 5
中
的
Request.IsAuthenticated函数
asp.net-core
在ASP.NET 5
中
是否有一个等同于Request.IsAuthenticated
的
东西隐藏在某个地方,或者我们需要遍历用户
的
身份并自己确定?
浏览 0
提问于2015-06-04
得票数 28
回答已采纳
1
回答
使用用户电子邮件更新公共字段
asp.net
、
entity-framework
、
entity-framework-core
、
identityserver4
、
asp.net-core-2.0
我正在尝试找出授权用户当前正在尝试保存数据并记录他们
的
电子邮件。我
的
dbcontext中有一个执行时间戳更新
的
基本设置,但是我不知道如何访问用户信息:{ ((BaseEntity)entity.Entity).ModifiedBy = currentUsername; }更多
的
背景这一切都建立在DBContext位于我<e
浏览 18
提问于2017-12-26
得票数 0
1
回答
如何从ASP.NET核心中
的
IHostedService获取网站地址或访问HttpContext?
asp.net-core
、
.net-core
、
httpcontext
、
base-url
、
asp.net-core-hosted-services
在我们
的
MultiTenant ASP.NET Core2.2应用程序
中
,我们根据URI确定租户。public MyHostedService(ILogger<TurnTimeTask> logger,
浏览 40
提问于2019-07-12
得票数 0
1
回答
如何在.Net内核
中
为
IAntiForgery接口和
IHttpContextAccessor
创建实例
c#
、
asp.net-core
、
asp.net-core-webapi
、
antiforgerytoken
创建了一个类,它将创建AntiforgeryToken并验证令牌, 创建了一个方法,其中使用该属性
为
IAntiforgery创建了属性,只需访问GetAndStoreTokens,该方法
的
参数
为
httpContext,该参数是使用
IHttpContextAccessor
创建
的
属性传递
的
。在运行时,我
为
为
IHttpContextAccessor
和IAntiForgery创建
的
属性获取
空
实例,我知道我需
浏览 24
提问于2021-10-11
得票数 0
1
回答
为什么
IHttpContextAccessor
.HttpContext不正确
c#
、
asp.net-core
、
asp.net-core-2.0
这是我
的
密码。_httpContextAccessor; {HttpContext.Request.Headers["Authorization"]有我
的
令牌,IsAuthenticated是真的。 但是当我使用第二个代码时,它就不能工作了。HttpContext.Request.Headers["Authorization"]
为
<
浏览 0
提问于2018-06-29
得票数 1
回答已采纳
1
回答
.net核等价于IHttpContext和HttpApplication
c#
、
asp.net-core
我有使用System.Web.HttpContext
的
库,我正在迁移到.net内核。想知道我应该为IHttpContext和HttpApplication使用什么
浏览 1
提问于2017-03-14
得票数 2
1
回答
注入
的
依赖项
IHttpContextAccessor
为
空
。
c#
、
asp.net
、
.net
、
asp.net-core
、
blazor
当我试图调用此服务时,http上下文访问器
中
的
GetOrganization()方法
为
null。是什么导致了这个问题?public class ShopService private static
IHttpContextAccessor
?_httpContextAccessor; }
浏览 6
提问于2022-07-07
得票数 0
1
回答
如何在Signalr集线器
中
获得自己
的
身份
asp.net-mvc
、
authentication
、
signalr
、
owin
我有一个用ASP.NET MVC编写
的
应用程序,它使用SignalR和Owin外部身份验证(steam)。 { app.MapSignalR();} 不是
空
浏览 5
提问于2018-01-08
得票数 0
1
回答
在启动时获取数据库名称时,.NET核心HttpContext
为
空
.net-core
我有动态数据库
的
.NET核心应用程序,我从http请求(子域)。我在Startup.cs
中
执行以下操作{ services.AddDbContext<AppDbContext>((serviceProviderConfiguration.GetCo
浏览 9
提问于2021-09-14
得票数 0
1
回答
DBContext构造函数
中
的
用户声明有时
为
空
asp.net-core
、
entity-framework-core
我使用EF Core 3.1.7,并实现了一些全局查询过滤器来控制用户对几个表
中
的
一些数据
的
访问。查询过滤器需要当前登录
的
用户id (在我
的
identity实现
中
是一个整数),我将其保存在DBContext类
的
一个变量
中
。我通过注入
的
IHttpContextAccessor
访问DBContext构造函数
中
的
HttpContext,但发现有时通过DI (控制器=>数据访问服务=
浏览 35
提问于2020-08-27
得票数 0
1
回答
在ASP.NET MVC
中
清除会话
asp.net-mvc
、
filter
、
onactionexecuting
在
ActionFilterAttribute
中
,Session_Start调用和OnActionExecuting之间
的
会话发生了什么。protected void Session_Start(object sender, EventArgs e) Session["GoToBuyPage"] = true;并尝试在
ActionFilterAttribute
中
访问它: public override void OnActionExecuting(ActionExecu
浏览 9
提问于2012-07-14
得票数 0
点击加载更多
扫码
添加站长 进交流群
领取专属
10元无门槛券
手把手带您无忧上云
相关
资讯
Django2中DateTime字段查询时QuerySet为空的解决方案
在df的一列中 有None和Nan 我想把这些空值都填充为-1 应该怎么操作呢
Web API 之数据验证与单元测试
ASP.NET Core 2.0 MVC项目实战
Kotlin 空安全最佳实践
热门
标签
更多标签
活动推荐
运营活动
广告
关闭
领券