我有使用Entity Framework 5持久化的POCO域实体.它们是使用存储库模式从DbContext获得的,并通过UoW模式暴露给RESTful MVC WebApi应用程序.POCO实体是代理并且是延迟加载的.
我将我的实体转换为DTO,然后再将它们发送给客户端.我正在使用Automapper执行此操作,它似乎可以正常工作,Automapper将代理POCO映射到DTO,保持导航属性不变.我正在使用以下映射:
Mapper.CreateMap<Client, ClientDto>();
Run Code Online (Sandbox Code Playgroud)
域/ DTO对象的示例:
[Serializable]
public class Client : IEntity
{
public int Id { get; set; }
[Required, MaxLength(100)]
public virtual string Name { get; set; }
public virtual ICollection<ClientLocation> ClientLocations { get; set; }
public virtual ICollection<ComplianceRequirement> DefaultComplianceRequirements { get; set; }
public virtual ICollection<Note> Notes { get; set; }
}
public class ClientDto : DtoBase
{
public int Id { get; set; }
[Required, MaxLength(100)]
public string Name { get; set; …Run Code Online (Sandbox Code Playgroud) entity-framework dto automapper navigation-properties asp.net-web-api
问题:
我需要从 javascript 向服务器发送一个请求,其中包含一个设置的标头,该标头将在响应时重新加载整个浏览器窗口。
jQuery ajax 似乎无法完全加载浏览器窗口,只能重新定位文档。
本质上我想做一个 window.location.reload(true) 同时还设置一个请求标头。
我已经将IdentityServer3作为独立的身份服务器运行.
我有一个单独的MVC客户端,它使用Cookie和OpenIdConnect进行身份验证.我试图在其他事情中设置声明转换,并希望引用不同的声明类型,如下所示:
var givenName = id.FindFirst(Constants.ClaimTypes.GivenName);
var familyName = id.FindFirst(Constants.ClaimTypes.FamilyName);
var sub = id.FindFirst(Constants.ClaimTypes.Subject);
var roles = id.FindAll(Constants.ClaimTypes.Role);
Run Code Online (Sandbox Code Playgroud)
在IdentityServer3上,我引用这些Thinktecture.IdentityServer.Core.Constants但是在我的MVC客户端上,我认为我不应该Thinktecture.IdentityServer3只引用这些字符串常量?是否有建议在这种情况下使用的客户端库?我试着Thinktecture.IdentityModel和一些.NET引用,但没有人可以复制ClaimTypes在Thinktecture.IdentityServer.Core.Constants.我发现的最好的是,System.Security.Claims.ClaimTypes但似乎有几个缺失,例如FamilyName.
我看的第一个放置Thinktecture.IdentityModel但是很惊讶这些不存在.
那么什么是神奇的参考?或者Thinktecture.IdentityServer3只为这些字符串加载是否合适?
谢谢
编辑:所以我发现Thinktecture.IdentityModel.Client其中包含一个JwtClaimTypes似乎镜像的东西ClaimTypes.为什么这个以Jwt前缀命名?
我正在尝试访问从控制器调用的非控制器类中的 ActionContext,以便访问 ActionArguments 集合。
我可以调用 HttpContext.Current 因为它是一个 Web Api 应用程序,但是我不知道如何访问当前的 ActionContext。
我总是可以将上下文从调用控制器传递给类,但是有兴趣看看是否有办法做到这一点。
我知道这不是最好的方法。