MVC
Web forms
Web forms Tutorials

Error handling and debugging

Basically if an error will occur in a service method you're not going to see it, so in order to see it you need to use Firefox's Firebug plugin, and then you'll see them in Firebug's Console error messages, but this error messages will have a generic message and not the actual, because by default WCF hides them, so you need to do some changes in web.config to enable this,
now let's show this in details:

1. Add a behavior in system.serviceModel - behaviors - serviceBehaviors, here I named it "AjaBehavior", it has includeExceptionDetailInFaults="true" and this will make it display the actual error messages.
<system.serviceModel>
	<behaviors>
	    <serviceBehaviors>
			<behavior name="AjaBehavior">
				<serviceMetadata httpGetEnabled="true"/>
				<serviceDebug includeExceptionDetailInFaults="true"/>
			</behavior>
...
		</serviceBehaviors>
	</behaviors>
...
</system.serviceModel>


and now use this behavior by attaching it to each service that needs to show error messages like this:
<system.serviceModel>
...
	<services>
		<service name="YourWebAppNamespace.svc.Aja" behaviorConfiguration="AjaBehavior">
			<endpoint ... />
		</service>
...
	</services>
</system.serviceModel>
note that endpoint also has behaviorConfiguration but that's a different thing (just to exclude confusion).

2. Install Firefox and Firebug plugin.

3. Now we will create a service method that throws an error and look at it in the firebug.
here's the service method:
[WebGet]
[OperationContract]
public LookupResult ErrorList(string search, int page)
{
    throw new Exception("hi, this is an exception thrown by the ErrorList Service method");
}

and the control:
<o:AjaxList runat="server" SearchUrl="~/svc/Aja.svc/ErrorList"/>


4. Now run the application in Firefox and hit F12, this should open the Firebug, after click on the Console tab (you might also need to click on a small triangle near the "Console" word and choose "Enabled" to enable the console), after all this refresh the page and you'll see al the ajax requests that happen click on them and you should see detailed info about them (in our case the error message in the Response Tab of the Ajax request). firebug console