Redirection page
m (Lars moved page Error page to Redirection page: Better to use redirect instead of error)
No edit summary
Line 1: Line 1:
==== Handling incorrect URLs and responding with a good error message ====
=== Handling incorrect URLs ===
If your user requests an page on your site that doesn't exist, Turnkey will redirect the request to a viewmodel called ErrorView
If your user requests an page on your site that doesn't exist, Turnkey will redirect the request to a viewmodel called RedirectView


On this page you can put any user friendly message that you want to display.
On this page you can put any user friendly message that you want to display.


==== Catching error information ====
==== Responding with a good error message ====
If you add two variables in the '''ErrorView''' viewmodel, these will be filled with information about the error.
Showing a nice 404 error message is good and let's you send your users back to the main page.
* '''RawURL''', a string that will receive the URL path that brought the user to the error page
* '''ErrorCode''', a string that will receive the error code, for example 400
The ErrorView could for example look like this
[[File:ErrorPageViewmodel.png|none|thumb|393x393px]]


==== Further redirection ====
==== Further redirection ====
Line 16: Line 12:
This also makes it possible for you to add "shortcuts" to your application.
This also makes it possible for you to add "shortcuts" to your application.


==== Implementation details ====
=== Catching error information ===
If you add two variables in the '''RedirectView''' viewmodel, these will be filled with information about the reason the user ended up at the redirect page.
* '''RawURL''', a string that will receive the URL path that brought the user to the redirect/error page
* '''ErrorCode''', a string that will receive the error code, for example 400
The RedirectView could for example look like this
[[File:ErrorPageViewmodel.png|none|thumb|393x393px]]
 
=== Implementation details ===
This feature is implemented using settings in the web.config file, like this
This feature is implemented using settings in the web.config file, like this
  <httpErrors errorMode="Custom" existingResponse="Replace">
  <httpErrors errorMode="Custom" existingResponse="Replace">
   <remove statusCode="400"/>
   <remove statusCode="400"/>
   <error statusCode="400" responseMode="ExecuteURL" path="/DWV?v=ErrorView&amp;amp;ErrorCode=400"/>
   <error statusCode="400" responseMode="ExecuteURL" path="/DWV?v=RedirectView&amp;amp;ErrorCode=400"/>
   <remove statusCode="401"/>
   <remove statusCode="401"/>
   <error statusCode="401" responseMode="ExecuteURL" path="/DWV?v=ErrorView&amp;amp;ErrorCode=401"/>
   <error statusCode="401" responseMode="ExecuteURL" path="/DWV?v=RedirectView&amp;amp;ErrorCode=401"/>
   <remove statusCode="402"/>
   <remove statusCode="402"/>
   <error statusCode="402" responseMode="ExecuteURL" path="/DWV?v=ErrorView&amp;amp;ErrorCode=402"/>
   <error statusCode="402" responseMode="ExecuteURL" path="/DWV?v=RedirectView&amp;amp;ErrorCode=402"/>
   <remove statusCode="403"/>
   <remove statusCode="403"/>
   <error statusCode="403" responseMode="ExecuteURL" path="/DWV?v=ErrorView&amp;amp;ErrorCode=403"/>
   <error statusCode="403" responseMode="ExecuteURL" path="/DWV?v=RedirectView&amp;amp;ErrorCode=403"/>
   <remove statusCode="404"/>
   <remove statusCode="404"/>
   <error statusCode="404" responseMode="ExecuteURL" path="/DWV?v=ErrorView&amp;amp;ErrorCode=404"/>
   <error statusCode="404" responseMode="ExecuteURL" path="/DWV?v=RedirectView&amp;amp;ErrorCode=404"/>
  </httpErrors>
  </httpErrors>
This redirects errors using the [[DisplayWithVariables]] feature. It redirect to the view "ErrorView" and adds the error code. DWV is a short version of [[DisplayWithVariables]] that doesn't require a root object, which we don't have in this case.
This redirects errors using the [[DisplayWithVariables]] feature. It redirect to the view "RedirectView" and adds the error code. DWV is a short version of [[DisplayWithVariables]] that doesn't require a root object, which we don't have in this case.

Revision as of 14:09, 11 August 2020

Handling incorrect URLs

If your user requests an page on your site that doesn't exist, Turnkey will redirect the request to a viewmodel called RedirectView

On this page you can put any user friendly message that you want to display.

Responding with a good error message

Showing a nice 404 error message is good and let's you send your users back to the main page.

Further redirection

This feature can also be used to further redirect to other pages. In the example above there is a action button with an Interval set to 10 ms that in special cases redirect to the correct page in the application. You can add any lookup logic and have multiple actions that handles different URLs and errors.

This also makes it possible for you to add "shortcuts" to your application.

Catching error information

If you add two variables in the RedirectView viewmodel, these will be filled with information about the reason the user ended up at the redirect page.

  • RawURL, a string that will receive the URL path that brought the user to the redirect/error page
  • ErrorCode, a string that will receive the error code, for example 400

The RedirectView could for example look like this

ErrorPageViewmodel.png

Implementation details

This feature is implemented using settings in the web.config file, like this

<httpErrors errorMode="Custom" existingResponse="Replace">
  <remove statusCode="400"/>
  <error statusCode="400" responseMode="ExecuteURL" path="/DWV?v=RedirectView&amp;ErrorCode=400"/>
  <remove statusCode="401"/>
  <error statusCode="401" responseMode="ExecuteURL" path="/DWV?v=RedirectView&amp;ErrorCode=401"/>
  <remove statusCode="402"/>
  <error statusCode="402" responseMode="ExecuteURL" path="/DWV?v=RedirectView&amp;ErrorCode=402"/>
  <remove statusCode="403"/>
  <error statusCode="403" responseMode="ExecuteURL" path="/DWV?v=RedirectView&amp;ErrorCode=403"/>
  <remove statusCode="404"/>
  <error statusCode="404" responseMode="ExecuteURL" path="/DWV?v=RedirectView&amp;ErrorCode=404"/>
</httpErrors>

This redirects errors using the DisplayWithVariables feature. It redirect to the view "RedirectView" and adds the error code. DWV is a short version of DisplayWithVariables that doesn't require a root object, which we don't have in this case.

This page was edited 29 days ago on 03/26/2024. What links here