安全IIS托管WCF服务访问通过IE主办的WinForms用户控制

问题描述:

我必须使用窗体身份验证的ASP.Net网站。其中一个ASPX页面加载的IE中托管一个WinForms用户控件。该控件必须位于同一ASP.Net网站WCF服务的连接。

I have an ASP.Net site using Forms authentication. One of the aspx pages loads a WinForms user control hosted in IE. That control must connect with a WCF service located in the same ASP.Net web site.

我怎样才能让WCF服务安全吗?目前,我已经设置了WCF服务使用AspNetCompatibilityRequirements模式,但在IE浏览器承载的用户控件,因为它没有登录无法连接到WCF服务。

How can I make the WCF service secure? Currently I have set the WCF service to use AspNetCompatibilityRequirements mode but the user control hosted in IE can't connect to the WCF service as it isn't logged in.

基本上,我需要从ASPX页面中提取用户凭据并设置它们的用户控件,以便它可以登录到WCF服务。

Basically I need to extract the user credentials from the aspx page and set them on the user control so that it can log in to the WCF service.

这可能吗?还是有更好的办法?

Is this possible? Or is there a better way?

我想这个答案可能有你需要的一切:Passing FormsAuthentication cookie来WCF服务。你只需要当你实例化它的身份验证Cookie传递到你的控制。

I think this answer probably has everything you need: Passing FormsAuthentication cookie to a WCF service. You just need to pass the authentication cookie to your control when you instantiate it.

至于那里是一个更好的方法,我个人也不会举办IE里面一个WinForms控制。如果我拍摄的是什么最容易的我会去使用Silverlight。如果这是不可能的我会做Web服务的非肥皂和使用JQuery。

As to there being a better way, I personally wouldn't host a WinForms control inside IE. If I were shooting for what was easiest I'd go with Silverlight. If that isn't possible I would make the web service non-soap and use JQuery.