views:

169

answers:

1

Hi all,

I'am newbie in WCF Services. I Have asp.net page, and call it WCF Service (basic http binding).

In my WCF Service, I need get the asp.net context of user.

Any sample about it ?

how can I config the client and service ??

and what code source can I use ??

Greetings, thanks in advanced

A: 

So your current scenario is that the ASPX web page use forms authentication and it will call a WCF service, and you want to let the forms authenticated identity be transfered to WCF service.

I think here are two possible optiosn depend on whether the WCF service is within the same web application with the web page:

1) if aspx page and WCF service is in the same web application, you can turn on AspNetCompatiblity mode for WCF so that the HttpContext will be available to WCF service operation code.

WCF Services and ASP.NET

http://msdn.microsoft.com/en-us/library/aa702682.aspx

ASP.NET Compatibility Mode

http://blogs.msdn.com/b/wenlong/archive/2006/01/23/516041.aspx

2) if aspx page and WCF service is deployed in separate application(or across remote machine boundary), the authenticated identity cannot be flowed to WCF service since you're using forms authentication. And you can consider pass the authenticated identity's username to the WCF service through a custom SoapHeader:

Handling custom SOAP headers via WCF Behaviors

http://weblogs.asp.net/paolopia/archive/2008/02/25/handling-custom-soap-headers-via-wcf-behaviors.Aspx

WCF Custom Message Headers

http://blogs.microsoft.co.il/blogs/bursteg/archive/2006/04/23/141.aspx

I use option number 1.

I have this issue:

I have WebSite with asp.net pages. httpp://desiis:90/WebSite1

In this webSite, I have a Service WCF (service1.svc). httpp://desiis:90/WebSite1/services/Service1.svc

When I call to the service, I get this error: This collection already contains an address with scheme http

In my localhost all is OK.

Thanks in advanced

alhambraeidos