🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
Improved routes
This page was created by Hans.karlsen on 2021-03-14. Last edited by Wikiadmin on 2026-07-29.

You can use improved routes to create shorter, product-neutral URLs for Turnkey Angular applications, MVC views, and REST endpoints while keeping existing routes working.

Overview

Improved routes are alternative URL formats for applications hosted by Turnkey. They remove Turnkey and AngularApp from application URLs, put the MVC view name before its object reference, and put the REST ViewModel name before the HTTP verb.

The older route formats continue to function. Update links, bookmarks, integrations, and generated documentation to the improved format when you want the new URL structure. Do not assume that existing application links are automatically rewritten.

Route formats

Replace http://localhost:5052 in the examples with the host and port where your application runs.

Area Older route Improved route
Angular application http://localhost:5052/Turnkey/AngularApp#/ViewOneThing/11!1 http://localhost:5052/App#/ViewOneThing/11!1
MVC view http://localhost:5052/Turnkey/Display/11!1?view=ViewOneThingCopy http://localhost:5052/MVC/ViewOneThingCopy/11!1
REST GET, object reference as a query parameter http://localhost:5052/TurnkeyRest/Get?command=ViewOneThing&id=11!1 http://localhost:5052/Rest/ViewOneThing/Get?id=11!1
REST GET, object reference as a path segment Not shown in the older format http://localhost:5052/Rest/ViewOneThing/Get/11!1

In these examples:

  • ViewOneThing and ViewOneThingCopy are ViewModel names.
  • 11!1 is the root object reference used by the view.
  • Get is the REST verb.

Use an improved application route

Use the /App route when linking directly to an Angular application view.

  1. Identify the ViewModel route and root object reference used by the existing application URL.
  2. Replace /Turnkey/AngularApp# with /App#.
  3. Keep the view route and object reference after the hash unchanged.
  4. Test the link in the deployed application.

For example, change:

http://localhost:5052/Turnkey/AngularApp#/ViewOneThing/11!1

to:

http://localhost:5052/App#/ViewOneThing/11!1

Use an improved MVC route

Use the /MVC route when opening an MVC view. The improved route places the ViewModel name directly after /MVC and the object reference after the view name.

  1. Find the view query parameter in the older URL.
  2. Place that ViewModel name after /MVC/.
  3. Move the id value to the final path segment.
  4. Remove the older /Turnkey/Display/ path and ?view= query parameter.

For example, change:

http://localhost:5052/Turnkey/Display/11!1?view=ViewOneThingCopy

to:

http://localhost:5052/MVC/ViewOneThingCopy/11!1

Use an improved REST route

Use the /Rest route to expose a ViewModel as a REST endpoint. REST access is not enabled by the URL alone: set the RestAllowed tagged value on the ViewModel, then ensure that the caller is permitted by the ViewModel access groups. For the full setup, request handling behavior, and JSON response options, see HowTos:Expose REST Service.

The base improved REST pattern is:

<host>/Rest/<ViewModelName>/<Verb>/<rootobjref>

You can instead provide the object reference as the id query parameter:

<host>/Rest/<ViewModelName>/<Verb>?id=<rootobjref>

For example, these two GET URLs address the same ViewModel and root object:

http://localhost:5052/Rest/ViewOneThing/Get?id=11!1

http://localhost:5052/Rest/ViewOneThing/Get/11!1

REST verbs

The improved route format supports Get, Post, Put, Patch, and Delete. The ViewModel variable vRestVerb, when declared, receives the verb used for the request.

Example Meaning
/Rest/ViewOneThing/Get/11!1 Gets REST output from ViewOneThing for the supplied root object.
/Rest/ViewOneThing/Put/11!1 Calls the same ViewModel using the Put verb; vRestVerb receives Put when that variable exists.

Pass ViewModel variables

Declare String variables in the ViewModel to receive additional request parameters. Add them as URL query parameters.

For example, if ViewOneThing declares String variables MyVar and MyOtherVar, call:

http://localhost:5052/Rest/ViewOneThing/Get/11!1?MyVar=hello&MyOtherVar=world

Use a complete object ID. A GUID or an ID in the form xx|yyyy is appropriate; an abbreviated ID without a class identifier can cause problems.

Control actions by verb

Use an action's Disable/ReadOnly expression to control which actions run for a REST verb. For example, the expression below makes an action read-only for every verb except Put:

vRestVerb&lt;&gt;'Put'

Handle invalid routes

When a requested page cannot be found, Turnkey redirects to a ViewModel named RedirectView. You can use that ViewModel to show a user-friendly error, redirect users to a valid page, or implement URL shortcuts. See Documentation:Redirection page for the required variables and implementation details.

Why use improved routes?

Improved routes:

  • Are shorter than the older equivalents.
  • Do not expose Turnkey in the URL path.
  • Do not expose AngularApp in the Angular application URL.
  • Place the MVC ViewModel before the object reference.
  • Place the REST ViewModel before the verb.

See also