新建了一个非常简单的WCF Service,但是在IE中浏览时,提示下面的错误:
环境是 windows7 vs2010 sp1 IE9
The service encountered an error.
An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:System.ArgumentException: Specified value has invalid Control characters.Parameter name: value at System.Net.WebHeaderCollection.CheckBadChars(String name, Boolean isHeaderValue) at System.Net.WebHeaderCollection.Add(String name, String value) at System.Collections.Specialized.NameValueCollection.Add(NameValueCollection c) at System.ServiceModel.Activation.HostedHttpContext.HostedRequestContainer.System.ServiceModel.Channels.HttpRequestMessageProperty.IHttpHeaderProvider.CopyHeaders(WebHeaderCollection headers) at System.ServiceModel.Channels.HttpRequestMessageProperty.get_Headers() at System.ServiceModel.Description.ServiceMetadataExtension.TryGetHttpHostAndPort(Uri listenUri, Message request, String& host, Int32& port) at System.ServiceModel.Description.ServiceMetadataExtension.GetDynamicAddressWriter(Message request, Uri listenUri, Boolean removeBaseAddress) at System.ServiceModel.Description.ServiceMetadataExtension.GetWriteFilter(Message request, Uri listenUri, Boolean removeBaseAddress) at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.TryHandleMetadataRequest(Message httpGetRequest, String[] queries, Message& replyMessage) at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.ProcessHttpRequest(Message httpGetRequest) at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.Get(Message message) at SyncInvokeGet(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
已经找到原因了。 IIS安装时候没有选上 Framework3.5中的Http activation 和 Non-Http activation 。
请问楼主,您用的是IIS哪个版本,我也遇到这问题了!!!
IIS7