Maximum request length exceeded despite config values being set - asp.net-mvc-4

I am having some issues when uploaded files of greater than 4MB to blob storage using an MVC application that I am working on. I have added the necessary code in the web.config as shown below:
Within system.web
<httpRuntime maxRequestLength="1048576" executionTimeout="3600" />
Within system.webserver
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824" />
</requestFiltering>
</security>
I have rebuilt my web project and my azure project but I am still getting the maximum request length exceeded error. Any ideas what might be causing this? Stack trace is as follows:
[HttpException (0x80004005): Maximum request length exceeded.]
System.Web.HttpRequest.GetEntireRawContent() +12603644
System.Web.HttpRequest.GetMultipartContent() +221
System.Web.HttpRequest.FillInFormCollection() +357
System.Web.HttpRequest.EnsureForm() +110
System.Web.HttpRequest.get_Form() +16
System.IdentityModel.Services.WSFederationAuthenticationModule.IsSignInResponse(HttpRequestBase request) +32
System.IdentityModel.Services.WSFederationAuthenticationModule.CanReadSignInResponse(HttpRequestBase request, Boolean onPage) +129
System.IdentityModel.Services.WSFederationAuthenticationModule.OnAuthenticateRequest(Object sender, EventArgs args) +152
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165

I had a similar problem, the problem was silly
In my web.config there were already a httpRuntime tag with targetFramework attribute specified.
I created a second httpRuntime tag instead of add maxRequestLength in the already present httpRuntime tag. So my value was ignored.

Related

IIS Header too long

I use a lot of claims and store them in token. I encountered this error before only in swagger, and clearing cache always worked for me. However, now I see this error in production environment. Current "Authorization" header that is giving this error is ~16kb. I tried to increase "Authorization" header size in IIS, added these to web.config
<system.web>
<httpRuntime maxRequestLength="500000000" executionTimeout="120" />
</system.web>
<location path="." inheritInChildApplications="false">
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="500000000" />
</requestFiltering>
</security>
and added tried increasing limit in Kestrel:
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.ConfigureKestrel((context, options) =>
{
options.Limits.MaxRequestHeadersTotalSize = 1048576;
});
}
None of the above helped. I didn't find other solutions, what else can be done here?
As Lex Li said.
According to the MSDN,
https://support.microsoft.com/en-us/help/820129/http-sys-registry-settings-for-windows
We could try to set up the MaxRequestBytes property in the below Registration location.
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\HTTP\Parameters
If the property doesn’t exist, create and set up it.
The registry takes high priority as the driver is the entry point of
packets. It is also a server-wide setting for all incoming HTTP
packets.
Please refer to the below thread.
Do web.config header size limits override http.sys limits in the registry?
https://serverfault.com/questions/417113/iis-6-header-too-big-how-to-tune-this-iis-setting
How to increase size limit for HTTP header value in request for Azure IIS?

Could not load type ImageResizer.InterceptModule

ImageResizer is setup and working in our test and development environments, however we can not get it working in our production environment. I have setup the IIS site the same (except for the name etc) and have the same Web.config options (only ImageResizer related things in there).... and no dice. We keep getting the error below. We have already tried re-downloading the files, and we checked the other suggestions. All to no avail.
.NET Version 4.5.2.
dll version 4.0.4.934 (we also tried with 4.0.5)... same result.
At the very bottom of the error page, the following displays... which may explain things? .NET 4.5.2 is on the server but it looks like the site is not configured to use it, perhaps?:
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34274
Server Error in '/' Application.
Could not load type 'ImageResizer.InterceptModule'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Could not load type 'ImageResizer.InterceptModule'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): Could not load type 'ImageResizer.InterceptModule'.]
System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +12512121
System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +76
[ConfigurationErrorsException: Could not load type 'ImageResizer.InterceptModule'.]
System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +12425644
System.Web.Configuration.Common.ModulesEntry.SecureGetType(String typeName, String propertyName, ConfigurationElement configElement) +69
System.Web.Configuration.Common.ModulesEntry..ctor(String name, String typeName, String propertyName, ConfigurationElement configElement) +62
System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) +299
System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) +1262
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +133
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +404
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475
[HttpException (0x80004005): Could not load type 'ImageResizer.InterceptModule'.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12618980
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12458597
web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="resizer" type="ImageResizer.ResizerSection,ImageResizer" requirePermission="false" />
</configSections>
<resizer>
<!-- Unless you (a) use Integrated mode, or (b) map all requests to ASP.NET,
you'll need to add .ashx to your image URLs: image.jpg.ashx?width=200&height=20 -->
<pipeline fakeExtensions=".ashx" defaultCommands="autorotate.default=true" />
<diskcache dir="/cache" />
<plugins>
<add name="DiskCache" />
<!-- <add name="PrettyGifs" /> -->
<!-- <add name="SimpleFilters" /> -->
<!-- <add name="S3Reader" /> -->
</plugins>
</resizer>
<system.web>
<httpModules>
<!-- This is for IIS7/8 Classic Mode and Cassini-->
<add name="ImageResizingModule" type="ImageResizer.InterceptModule" />
</httpModules>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<!-- This is for IIS7/8 Integrated mode -->
<add name="ImageResizingModule" type="ImageResizer.InterceptModule" />
</modules>
</system.webServer>
</configuration>
Additional Error Info...
Could not load file or assembly 'ImageResizer' or one of its dependencies. The system cannot find the file specified.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'ImageResizer' or one of its dependencies. The system cannot find the file specified.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'ImageResizer' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Even though our test environment has the "bin" folder setup as a virtual directory in IIS, this did not work in our production environment. It most likely has to do with the way the drives and site roots and content are setup and stored.
Test VM:
IIS Site Root -> X:\some.site\wwww
"bin" virtual directory -> Y:\bin
Prod VM:
Does not work:
IIS Site Root -> X:\some.site\wwww (which is a symlink to a SAN share)
"bin" virtual directory -> C:\bin
Works:
"bin" is a directory in the site root (on the SAN share)
Thanks Nathanael for the help.
For my case, I accidentally changed the directory of the Default Website on IIS to the root folder of one of my projects whose web.config file includes the ImageResizingModule.
I fixed the issue by just changing the physical path of the Default Website on IIS to the wwwroot folder.

"A registration already exists for URI" when hosting same service for HTTPS and HTTP

I am trying to host the same service inside the same website using two endpoints one HTTP and the other HTTPS.
The problem is I can happily call one service (whichever I call first works) but then call to the other fails until I iisreset and try again. SO I can happily call both but one at a time until a process recycle.
I have exhausted (or I think I have) all relevant Q&A and documents that I could find and none of them seem to help me. The level of documentation of MSDN regarding these cases (which should be faily common) is appalling and nothing works as it seems.
I have used Host/BaseAddresses/BaseAddress with no luck and whenever I used it, I get another error (cannot find an HTTPS scheme).
I have folder called Secure which is enabled for HTTPS inside IIS.
I have disabled mex so no metadata allowed which I got passed previous errors.
Anyone got a clue? I am cluless...
<service name="Namespace.MyService" behaviorConfiguration="MyBehaviour">
<host>
<baseAddresses>
</baseAddresses>
</host>
<endpoint address="http://localhost/Services/MyService.svc/MyService"
name="MyService" binding="wsHttpBinding"
bindingConfiguration="myWsHttpBinding" contract="Namespace.IMyService" />
<endpoint address="https://localhost/Services/Secure/MySslService.svc/MySslService"
name="MySslService" binding="basicHttpBinding"
bindingConfiguration="MySslServiceBinding" contract="Namespace.IMyService" />
</service>
.....
<behavior name="MyBehaviour">
<custom1/>
<custom2/>
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false"/>
<serviceAuthorization principalPermissionMode="UseAspNetRoles" roleProviderName="CustomProvider"/>
<serviceCredentials>
<serviceCertificate findValue="Some" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="SomeClass, SomeDll"/>
</serviceCredentials>
</behavior>
Original error is:
A registration already exists for URI
'http://localhost/Services/....'.
Description: An unhandled exception
occurred during the execution of the
current web request. Please review the
stack trace for more information about
the error and where it originated in
the code.
Exception Details:
System.InvalidOperationException: A
registration already exists for URI
'http://localhost/Services/....'.
Source Error:
An unhandled exception was generated
during the execution of the current
web request. Information regarding the
origin and location of the exception
can be identified using the exception
stack trace below.
Stack Trace:
[InvalidOperationException: A
registration already exists for URI
System.ServiceModel.Channels.UriPrefixTable1.RegisterUri(Uri
uri, HostNameComparisonMode
hostNameComparisonMode, TItem item)
+320 System.ServiceModel.Channels.HttpTransportManager.Register(TransportChannelListener
channelListener) +380
System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener
channelListener) +816
System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback
selectTransportManagerCallback) +121
System.ServiceModel.Channels.HttpChannelListener.OnOpen(TimeSpan
timeout) +125
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
timeout) +789
System.ServiceModel.Channels.DatagramChannelDemuxer2.OnOuterListenerOpen(ChannelDemuxerFilter
filter, IChannelListener listener,
TimeSpan timeout) +606
System.ServiceModel.Channels.SingletonChannelListener`3.OnOpen(TimeSpan
timeout) +91
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
timeout) +789
System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan
timeout) +375
Here is the WCF Trace log error:
The ChannelDispatcher at
'http://localhost/Services/...' with
contract(s) '"IMyService"' is unable
to open its IChannelListener.
System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan
timeout)
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
timeout)
System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan
timeout)
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
timeout)
System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String
normalizedVirtualPath)
System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String
normalizedVirtualPath)
System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String
relativeVirtualPath)
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest()
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest()
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequest(Object
state)
System.ServiceModel.AspNetPartialTrustHelpers.PartialTrustInvoke(ContextCallback
callback, Object state)
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequestWithFlow(Object
state)
System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32
errorCode, UInt32 numBytes,
NativeOverlapped* nativeOverlapped)
System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32
error, UInt32 bytesRead,
NativeOverlapped* nativeOverlapped)
System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32
errorCode, UInt32 numBytes,
NativeOverlapped* pOVERLAP)
OK, I fixed my problem. The issue was I was under impression that I had to create a secure folder in IIS and put the .svc file in there to guarantee SSL transmission. It turned out that it is not the case and all I had to do was to use the same .svc file and just define 2 endpoints:
<endpoint address="http://localhost/Services/MyService.svc/MyService"
name="MyService" binding="wsHttpBinding"
bindingConfiguration="myWsHttpBinding" contract="Namespace.IMyService" />
<endpoint address="https://localhost/Services/MyService.svc/MySecureService"
name="MySslService" binding="basicHttpBinding"
bindingConfiguration="MySslServiceBinding" contract="Namespace.IMyService" />
It's possible the nested directories are confusing IIS - I have had this happen before although not in the WCF context. Try changing the endpoint addresses to:
address="http://localhost/MyService"
address="https://localhost/MySslService"
Can you try hosting the application from a console app instead of IIS? I'm pretty certain IIS is causing your problem somehow but this might confirm it.
If it's possible, I'd also try to isolate the problem by removing some of the configuration detail - eg bindingConfiguration and behaviorConfiguration.
Obviously these are just debugging steps I'd perform (you may have already) to try and isolate the problem - sorry I haven't got a full answer.

Problem in Hosting WCF Service using wsHttpBinding in IIS

I am trying to host my service using following configuration.
<system.serviceModel>
<services>
<service name="Test.MyService" behaviorConfiguration="MyServiceBehavior">
<!-- Service Endpoints -->
<endpoint address="MyTestService" binding="wsHttpBinding" bindingConfiguration="WebserviceHttpBinding" contract="Test.IMyService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="WebserviceHttpBinding">
<security mode="Message">
<message clientCredentialType="UserName" negotiateServiceCredential="false"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Test.CredentialValidator, Test"/>
<serviceCertificate findValue="RPKey" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My"/>
</serviceCredentials>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
When I debug this service, I am having no problem. I hosted this service in IIS using Website. When I browse this service from IIS I am getting following exception.
Server Error in '/MyTestService'
Application.
Keyset does not exist
Description: An unhandled exception
occurred during the execution of the
current web request. Please review the
stack trace for more information about
the error and where it originated in
the code.
Exception Details:
System.Security.Cryptography.CryptographicException:
Keyset does not exist
Source Error:
An unhandled exception was generated
during the execution of the current
web request. Information regarding the
origin and location of the exception
can be identified using the exception
stack trace below.
Stack Trace:
[CryptographicException: Keyset does not exist
]
System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer) +369
System.Security.Cryptography.Utils.GetKeyPairHelper(CspAlgorithmType keyType, CspParameters parameters, Boolean randomKeyContainer, Int32 dwKeySize, SafeProvHandle& safeProvHandle, SafeKeyHandle& safeKeyHandle) +151
System.Security.Cryptography.RSACryptoServiceProvider.GetKeyPair() +85
System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32 dwKeySize, CspParameters parameters, Boolean useDefaultKeySize) +280
System.Security.Cryptography.X509Certificates.X509Certificate2.get_PrivateKey() +468
System.ServiceModel.Security.SecurityUtils.EnsureCertificateCanDoKeyExchange(X509Certificate2 certificate) +85
[ArgumentException: The certificate 'CN=RPKey' must have a private key that is capable of key exchange. The process must have access rights for the private key.]
System.ServiceModel.Security.SecurityUtils.EnsureCertificateCanDoKeyExchange(X509Certificate2 certificate) +15832031
System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateServerX509TokenProvider() +45
System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateLocalSecurityTokenProvider(RecipientServiceModelSecurityTokenRequirement recipientRequirement) +73
System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateSecurityTokenProvider(SecurityTokenRequirement requirement) +65
System.ServiceModel.Security.SessionRenewSecurityTokenManager.CreateSecurityTokenProvider(SecurityTokenRequirement requirement) +14
System.ServiceModel.Security.SymmetricSecurityProtocolFactory.OnOpen(TimeSpan timeout) +15334232
System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout) +23
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +563
System.ServiceModel.Security.SecurityListenerSettingsLifetimeManager.Open(TimeSpan timeout) +101
System.ServiceModel.Channels.SecurityChannelListener1.OnOpen(TimeSpan timeout) +203
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +563
System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) +87
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +563
System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +110
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +563
System.ServiceModel.Security.SecuritySessionSecurityTokenAuthenticator.OnOpen(TimeSpan timeout) +149
System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout) +23
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +563
System.ServiceModel.Security.SecurityUtils.OpenCommunicationObject(ICommunicationObject obj, TimeSpan timeout) +24
System.ServiceModel.Security.SecuritySessionServerSettings.OnOpen(TimeSpan timeout) +878
System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout) +23
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +563
System.ServiceModel.Security.SecurityListenerSettingsLifetimeManager.Open(TimeSpan timeout) +153
System.ServiceModel.Channels.SecurityChannelListener1.OnOpen(TimeSpan timeout) +203
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +563
System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) +87
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +563
System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +110
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +563
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +135
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +654
[ServiceActivationException: The service '/AtlasServices/Service.svc' cannot be activated due to an exception during compilation. The exception message is: The certificate 'CN=RPKey' must have a private key that is capable of key exchange. The process must have access rights for the private key..]
System.ServiceModel.AsyncResult.End(IAsyncResult result) +15700960
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +15623609
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, Boolean flowContext) +265
System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +227
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171
This is propabely because on the IIS the account settings are different from the account that you are using to run a local server.
are you working with an X.509 certificate?
If so, are you sure you gave read acces privileges to the account that is running the process (that is running IIS) for the file containing the private key?
So if IIS is running under the account Saghar, does Saghar have read privilesges for the key file ?
#update
ArgumentException: The certificate 'CN=RPKey' must have a private key that is capable of key exchange. The process must have access rights for the private key.
this tells me that your IIS account doesn't have permissions to your private key
Based on the exception report, it sounds like one of two things may be happening. The certificate you are referencing was either installed into the keystore with only the public key, or the installed certificate is restricted and the account your application pool is running under does not have permission to access the key.
The former case is very easy to run into if the x.509 certificate was not exported as a .pfx, but instead as a .cer. To exchange certificates that contain a private key, the .cer format is insufficient, as it can only contain a DER encoded x.509 public key certificate. You must export your certificate from a certificate server (or from a store that has both keys) as a .pfx file, and make sure you include the private key.
If it is the latter case, then you need to make sure the account of the application pool your service is running under in IIS has permission to access the certificate store the keys are contained within. This article may be helpful: Make X.509 Certificates Accessible to WCF
IIS application pool identity does not have access to certificate
Set application pool identity to NETWORK SERVICE
install rktools
run "c:\Program Files (x86)\Windows Resource Kits\Tools\winhttpcertcfg.exe" -g -c LOCAL_MACHINE\My -s WSE2QuickStartServer -a "NETWORK SERVICE"
If you do not require wshttpbinding, just try changing to basichttpbinding and your issue will probably go away.
We had trouble with this in the past when the client was connecting from a site outside our network. Since the connection was over vpn we had the option of abandoning security for the binding.

There was an error generating the XML document when using Windows authentication pass-through

I've set up a basic http WCF Service and my application in IIS is configured to use Windows Authentication.
The bindings therefore have the following security settings:
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="None" />
<message clientCredentialType="Certificate"/>
</security>
Each operation contract has the following attribute
[PrincipalPermission(SecurityAction.Demand, Authenticated = true)]
and the service class has the following attribute to allow asp compability
[AspNetCompatibilityRequirements(RequirementsMode =
AspNetCompatibilityRequirementsMode.Allowed)]
The Windows authentication is passed to the WCF service properly, since I can see/generate the WSDL. However, when I call an operation in my WCF service i get the following error:
[FaultException`1: There was an error generating the XML document.]
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,
IMessage retMsg) +4767763
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData,
Int32 type) +1725
XXXX.Service() +0
XXXX.Service() +329
XXXX.Service() +747
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o,
Object t,EventArgs e) +25
System.Web.UI.Control.LoadRecursive() +71
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,
Boolean includeStagesAfterAsyncPoint) +3048
It's not the first time i see the error There was an error generating the XML document., I want to know what could be the reason for this? Does the Service send the data somewhat encrypted and the client doesn't understand it because it is miss-configured?
Looks like the you are not handling an exception/Fault in your code, you may want to ensure your serialising the error correctly, using the following
http://blogs.msdn.com/b/pedram/archive/2008/01/25/wcf-error-handling-and-some-best-practices.aspx
I have also found a blog entry from Mike Taulty very good for enableing logging in WCF
http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2005/12/15/5662.aspx
Hope this helps.