Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,
I have one asp.net(c#) application and a asp.net enabled wcf service hosted in same port as two virtual directories. i have configured form authentication for both asp.net and asp.net enabled wcf service. When i am calling method in WCF Service from asp.net without forms authentication everything working fine. When i enable the forms authentication in wcf service . I get the following error with the contents of login page due to the unauthenticated service call.
I have pasted the some part of response below

The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were"

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>


I have tried the solution, i get from net by adding current authentication cookie using following code but i get the same issue.
HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty();
httpRequestProperty.Headers.Add(HttpRequestHeader.Cookie, FormsAuthentication.GetAuthCookie(User.Identity.Name, false).Value);
ServiceReference1.Service1Client serviceClient = new ServiceReference1.Service1Client();
using (OperationContextScope scope = new OperationContextScope(serviceClient.InnerChannel))
{
OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty;
string s = serviceClient.GetData(2);
}



I look forward for your reply. Tired of searching for the solution...

Thanks in advance.
Posted
Updated 9-Dec-10 19:58pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900