Router

public abstract partial class Router : DirectController
The router handles the batch requests from ExtJS/Sencha Touch client code. The protocol described in "Ext Direct" standard http://www.sencha.com/products/extjs/extdirect. When an error occurs router return Error(Exception) result. You can change this behavior by overriding OnRoutingException, OnRequestException, RequestExecuting and RequestExecuted.

Router registration

In order for the router started to process incoming requests from your's client code, it should be registered. To register your router in ASP.NET MVC you need to add/include Sencha.Direct namespace and execute RegisterDirectRouter() on routes collection;

using Sencha.Direct;

// ... (RouteCollection routes)

routes.RegisterDirectRouter();

If you are using the zone, each zone must be registered with its own router:

using Sencha.Direct;

// ... (AreaRegistrationContext context)

context.RegisterDirectRouter();

Logging

By registering your own implementation of the router, you can override OnRoutingException, OnRequestException, RequestExecuting and RequestExecuted methods. These methods are called during the execution of incoming requests and can help you debug/log your application.

Example of registering your own router:
using Sencha.Direct;

// ...

class TracedRouter : Router
{
	protected override void OnRoutingException(ExceptionContext context)
	{
		Trace.TraceError(context.Exception.ToString());
	}
}

// ...

routes.RegisterDirectRouter<TracedRouter>();


Last edited Apr 27, 2012 at 3:01 PM by ShaiHulud, version 6

Comments

No comments yet.