使用带有Session的ServiceStack Ormlite全局过滤器

时间:2017-03-28 14:00:24

标签: servicestack ormlite-servicestack

我想更改找到here的示例,以便每次进行更改时都会使用会话的用户名填充modifyby。这可能吗?

1 个答案:

答案 0 :(得分:2)

您需要单独访问才能访问您需要在df <- structure(list(Unresolved = c(5L, 6L, 7L, 8L, 9L, 10L, 5L, 6L, 7L, 8L, 9L, 10L), Metric = c("New.NPS", "New.NPS", "New.NPS", "New.NPS", "New.NPS", "New.NPS", "Old.NPS", "Old.NPS", "Old.NPS", "Old.NPS", "Old.NPS", "Old.NPS"), Score = c(66.48, 65.32, 64.16, 63, 61.84, 60.68, 68.5, 62.28, 61.74, 61.41, 61.67, 60.42)), .Names = c("Unresolved", "Metric", "Score"), row.names = c(NA, -12L), class = "data.frame") 或ASP.NET的ReqeustContext字典中填充的UserName,例如:

HttpContext.Current.Items

您可以从GlobalRequestFilters.Add((req,res,dto) => { RequestContext.Instance.Items["UserName"] = req.GetSession().UserAuthName; }); 内部访问,例如:

UpdateFilter

注意:&#34; UserName&#34;只能在HTTP请求的上下文中工作。