ASP.NET MVC 5 - IdentityUser在WCF? [英] ASP.NET MVC 5 - IdentityUser in WCF?

查看:199
本文介绍了ASP.NET MVC 5 - IdentityUser在WCF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在写,将使用ASP.NET身份来执行所有成员和索赔相关的东西WCF服务。 (也就是说,认证,注册,都将通过调用WCF这种执行)

I am currently writing a WCF service that will use ASP.NET Identity to perform all membership and claims related stuff. (That is, authentication, registration, and all will be performed by calling this WCF)

[DataContract(IsReference=true)]
public class ApplicationUser: IdentityUser
{
    [DataMember]
    public string FirstName { get; set; }
    [DataMember]
    public string LastName { get; set; }
    [DataMember]
    public string Email { get; set; }
}

问题是,IdentityUser是Microsoft.Aspnet.Identity.Core.Entityframework装配一个类,这个类没有打上DataContract属性。
我写在我的操作
WCF服务ApplicationUser返回给调用网站。

The problem is that "IdentityUser" is a class in Microsoft.Aspnet.Identity.Core.Entityframework assembly, and this class is not marked with DataContract attribute. I am writing an operation in my WCF service to return ApplicationUser to the calling website.

如何实现这个任何想法?

Any idea of how to achieve this?

推荐答案

创建具有具有相同的属性ApplicationUser类数据契约数据传输对象(DTO)。你必须从你的DTO到ApplicationUser,以及其他的方式做了改造。使用AutoMapper做转型。

Create a data transfer object (DTO) that has a data contract that has the same properties as the ApplicationUser class. You will have to do a transformation from your DTO to the ApplicationUser, and the other way. Use AutoMapper to do the transformation.

我个人不认为把安全背后一个WCF Web服务的任何实际的好处。网络hop和序列化/反序列化对每个授权是真的要狗Web应用程序。

Personally I do not see any real benefit of putting security behind a WCF web service. A network hop and serialization/deserialization on every authorization is really going to dog your web application.

这是一个好主意,将其分离成不同的层,但是该层不必是成为一个Web服务。看看 SimpleSecurity 。它提供了ASP.NET身份的一层,并演示如何自定义为确认电子邮件和其它增强功能。因为它是打从Web客户端的每个请求你的授权功能不分配一个很好的项目。

It is a good idea to separate it into a different layer, but that layer does not have be to be a web service. Take a look at SimpleSecurity. It provides a layer over ASP.NET Identity and demonstrates how to customize it for email confirmation and other enhanced functionality. Your authorization functionality is not a good item to distribute because it is hit for every request from the web client.

这篇关于ASP.NET MVC 5 - IdentityUser在WCF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆