CRM 2011 Web Page Error: The server was unable to process the request due to an internal error either from ServiceBehaviorAttribute or from the configuration behavior

I was working with a web application which connects to the CRM 2011 Organization Web Service. While developing it through Visual Studio the application was working like a charm! And as soon as I published it to the IIS 7, it began showing me following error and stack trace.

The server was unable to process the request due to an internal error.  For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.

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.ServiceModel.FaultException: The server was unable to process the request due to an internal error.  For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.

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:

[FaultException: The server was unable to process the request due to an internal error.  For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.]
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +4767763
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +1725
Microsoft.Xrm.Sdk.IOrganizationService.Execute(OrganizationRequest request) +0
Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.ExecuteCore(OrganizationRequest request) +892
xxxxxxxTool.xxxxxContacts.Page_Load(Object sender, EventArgs e) in C:\Users\Administrator\Desktop\xxxxxxxTool\xxxxxxxTool\xxxxxContacts.aspx.cs:173
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

Looking at the error details, I was not sure what was wrong with a piece of code I wrote! I didn’t even used .Net Framework 3.0 SDK?!? With some findings on net I found some attributes for ServiceBehaviors that should be added to web.config shown as below.

<behaviors>
  <serviceBehaviors>
    <behavior name="SecurityTokenServiceBehavior">
      <!--The serviceMetadata behavior allows one to enable metadata (endpoints, bindings, services) publishing.
This configuration enables publishing of such data over HTTP GET.
This does not include metadata about the STS itself such as Claim Types, Keys and other elements to establish a trust.-->
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
      <!--Default WCF throttling limits are too low-->
      <serviceThrottling maxConcurrentCalls="65536" maxConcurrentSessions="65536" maxConcurrentInstances="65536" />
    </behavior>
  </serviceBehaviors>
</behaviors>

This was not sufficient as error was still there! I thought I had a problem with my IIS, I reinstalled it! Still there is same error. I checked to the other PCs but the issue persisted. Finally I got the solution by some R&D on IIS part.

Through MSDN I found that the Applications made for CRM or using any web services of CRM 2011 will need the same configuration as CRM App Pool. If the application will not consume more, you can use the same App Pool that CRM 2011 web application uses.

The Similar AppPool created for the application must be running on Classic mode and Identity should be Network Service.

And some authentication settings to the web application developed for the CRM will help the application run without issues on IIS 7. Follow this image for Authentication to web application to set.

Authentication Settings

Authentication Settings

Anonymous Authentication should be Disabled. CRM needs Windows Authentication, Enable it. And there is no need to have a Forms Authentication, Disable it.

After all these settings your application should work as expected.

Happy Troubleshooting!!

Advertisements

3 thoughts on “CRM 2011 Web Page Error: The server was unable to process the request due to an internal error either from ServiceBehaviorAttribute or from the configuration behavior

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s