MVC-Style Custom Routing

posted Nov 30, 2018, 12:46 PM by Eric Patrick   [ updated Dec 14, 2018, 5:51 AM ]
QBO3 now supports custom routes, including RESTful-compliant routes.

This is a breaking change: the HttpHandler and HttpAsyncHandler have been tweaked, and all .ashx handler must be re-complied against this change to work. Do not deploy qbo.Application.dll without also deploying all other modules.

Custom routes are defined in CustomRoutes.config, and the web.config must be modified to include these entries:

<section name="Routes" type="qbo.Application.Configuration.CustomRouteConfiguration, qbo.Application"/>
...
<Routes configSource="config\CustomRoutes.config" />

Standard routes include:

<?xml version="1.0"?>
<Routes>
  <CustomRoutes>
    <CustomRoute Name="Default-1-Queue" Url="api/{class}/queue/{operation}"/>
    <CustomRoute Name="Default-2-Parent" Url="api/{Object}/{ObjectID:int}/{class}/{operation}"/>
    <CustomRoute Name="Default-3-Singleton" Url="api/{class}/{operation}/{id:int}"/>
    <CustomRoute Name="Default-4-Default" Url="api/{class}/{id:int}"/>
    <CustomRoute Name="Default-5-Any" Url="api/{class}/{operation}"/>
    <CustomRoute Name="Default-6-Documents" Url="documents/{operation}" MethodSignature="Attachment/{operation}"/>
    <CustomRoute Name="Default-8-Upload" Url="documents/uploadchunk" MethodSignature="Attachment/UploadChunk" Handler="qbo.AttachmentWeb.Attachment, qbo.AttachmentWeb"/>
  </CustomRoutes>
</Routes>

Errors from Incomplete Deployments


If you deploy qbo.Application.dll without rebuilding associated web project, you will get an error along these lines:

Field not found: 'qbo.Application.HttpAsyncHandler.QueueOperation'.

To fix this error, recompile and redeploy all projects.
Comments