U4-2691 - Using template name in the URL returns the front page template when using umbracoInternalRedirectId

Created by Emil Rasmussen 22 Aug 2013, 09:50:30 Updated by Stefan Kip 23 Feb 2016, 08:36:28

When trying to use the template name as a URL (E.g. http://umbraco.local/testtemplate/) the front page is returned - I have attached a screen shot from the Control Tree section of the umbDebugShowTrace output.

Sample Umbraco installation with SQL CE database can be provided if needed.

1 Attachments

Comments

Stephan 26 Aug 2013, 14:07:41

Can you try without the trailing slash? Also... umbraco.local/testtemplate should display the home page, using the testtemplate template -- is that what you expect?

Can you enable debug in log4net.config (top of the file, set ) then run again and check App_Data/logs/UmbracoTraceLog.txt file? Maybe post the relevant part here?


Emil Rasmussen 27 Aug 2013, 06:49:31

Trailing slash or not doesn't make a difference.

Umbraco.local/testtemplate displays the home page, but with the front page's template.

You asked me to turn up the logging level, and while investigating the log, I found the bug. We are using umbracoInternalRedirectId, and that messes it up big time (it works as intended with umbracoInternalRedirectId) Look at the log below:

2013-08-27 08:36:29,208 [59] DEBUG Umbraco.Web.UmbracoModule - [Thread 49] Begin request: http://umbraco.local/testtemplate/. 2013-08-27 08:36:29,260 [59] DEBUG umbraco.content - [Thread 49] Initializing content on thread '' (Threadpool? True) 2013-08-27 08:36:29,263 [59] INFO umbraco.content - [Thread 49] Loading content from disk cache... 2013-08-27 08:36:29,265 [59] DEBUG umbraco.content - [Thread 49] Content initialized (loaded) 2013-08-27 08:36:29,278 [59] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 49] FindDomain: Uri="http://umbraco.local/testtemplate" 2013-08-27 08:36:29,329 [59] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 49] FindDomain: Matches no domain 2013-08-27 08:36:29,338 [59] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 49] FindDomain: Culture="en-US" 2013-08-27 08:36:29,339 [59] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 49] FindPublishedContentAndTemplate: Path="/testtemplate" 2013-08-27 08:36:29,341 [59] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 49] FindPublishedContent: Begin finders 2013-08-27 08:36:29,345 [59] DEBUG Umbraco.Web.Routing.ContentFinderByNiceUrl - [Thread 49] Test route "/testtemplate" 2013-08-27 08:36:29,358 [59] DEBUG Umbraco.Web.Routing.ContentFinderByNiceUrl - [Thread 49] No match. 2013-08-27 08:36:29,360 [59] DEBUG Umbraco.Web.Routing.ContentFinderByIdPath - [Thread 49] Not a node id 2013-08-27 08:36:29,369 [59] DEBUG Umbraco.Web.Routing.NotFoundHandlerHelper - [Thread 49] Registering custom handlers. 2013-08-27 08:36:29,371 [59] DEBUG Umbraco.Web.Routing.NotFoundHandlerHelper - [Thread 49] Registering 'umbraco.SearchForAlias,umbraco'. 2013-08-27 08:36:29,371 [59] DEBUG Umbraco.Web.Routing.NotFoundHandlerHelper - [Thread 49] Registering 'umbraco.SearchForTemplate,umbraco'. 2013-08-27 08:36:29,371 [59] DEBUG Umbraco.Web.Routing.NotFoundHandlerHelper - [Thread 49] Registering 'umbraco.SearchForProfile,umbraco'. 2013-08-27 08:36:29,371 [59] DEBUG Umbraco.Web.Routing.NotFoundHandlerHelper - [Thread 49] Registering 'umbraco.handle404,umbraco'. 2013-08-27 08:36:29,374 [59] DEBUG Umbraco.Web.Routing.ContentFinderByNotFoundHandlers - [Thread 49] Running for legacy url='testtemplate'. 2013-08-27 08:36:29,377 [59] DEBUG Umbraco.Web.Routing.ContentFinderByNotFoundHandlers - [Thread 49] Handler 'umbraco.SearchForAlias'. 2013-08-27 08:36:29,377 [59] DEBUG Umbraco.Web.Routing.ContentFinderByNotFoundHandlers - [Thread 49] Replace handler 'umbraco.SearchForAlias' by new finder 'Umbraco.Web.Routing.ContentFinderByUrlAlias'. 2013-08-27 08:36:29,381 [59] DEBUG Umbraco.Web.Routing.ContentFinderByNotFoundHandlers - [Thread 49] Handler 'umbraco.SearchForTemplate'. 2013-08-27 08:36:29,381 [59] DEBUG Umbraco.Web.Routing.ContentFinderByNotFoundHandlers - [Thread 49] Replace handler 'umbraco.SearchForTemplate' by new finder 'Umbraco.Web.Routing.ContentFinderByNiceUrlAndTemplate'. 2013-08-27 08:36:29,550 [59] DEBUG Umbraco.Web.Routing.ContentFinderByNiceUrlAndTemplate - [Thread 49] Valid template: "testtemplate" 2013-08-27 08:36:29,550 [59] DEBUG Umbraco.Web.Routing.ContentFinderByNiceUrl - [Thread 49] Test route "/" 2013-08-27 08:36:29,567 [59] DEBUG Umbraco.Web.Routing.ContentFinderByNiceUrl - [Thread 49] Got content, id=1052 2013-08-27 08:36:29,573 [59] DEBUG Umbraco.Web.Routing.ContentFinderByNotFoundHandlers - [Thread 49] Finder 'Umbraco.Web.Routing.ContentFinderByNiceUrlAndTemplate' found node with id=1052. 2013-08-27 08:36:29,574 [59] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 49] FindPublishedContent: End finders, a document was found (took 230ms) 2013-08-27 08:36:29,578 [59] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 49] HandlePublishedContent: Begin 2013-08-27 08:36:29,602 [59] INFO Umbraco.Core.PluginManager - [Thread 49] Starting resolution types of Umbraco.Core.Persistence.Mappers.BaseMapper 2013-08-27 08:36:29,611 [59] INFO Umbraco.Core.PluginManager - [Thread 49] Completed resolution of types of Umbraco.Core.Persistence.Mappers.BaseMapper, found 17 (took 8ms) 2013-08-27 08:36:29,847 [59] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 49] FollowInternalRedirects: Found umbracoInternalRedirectId=1053 2013-08-27 08:36:29,850 [59] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 49] FollowInternalRedirects: Redirecting to id=1053 2013-08-27 08:36:29,860 [59] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 49] EnsurePublishedContentAccess: Page is not protected 2013-08-27 08:36:29,860 [59] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 49] HandlePublishedContent: End 2013-08-27 08:36:29,867 [59] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 49] FindTemplate: Look for template id=1046 2013-08-27 08:36:29,877 [59] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 49] FindTemplate: Got template id=1046 alias="FrontPage" 2013-08-27 08:36:29,877 [59] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 49] FindTemplate: Running with template id=1046 alias="FrontPage" 2013-08-27 08:36:29,883 [59] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 49] HandleWildcardDomains: Path="-1,1052,1053" 2013-08-27 08:36:29,885 [59] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 49] HandleWildcardDomains: No match. 2013-08-27 08:36:29,895 [59] DEBUG Umbraco.Web.UmbracoModule - [Thread 49] Response status: Redirect=none, Is404=false, StatusCode=0 2013-08-27 08:36:29,914 [59] DEBUG umbraco.UmbracoDefault - [Thread 49] PreInit 2013-08-27 08:36:29,922 [59] DEBUG umbraco.UmbracoDefault - [Thread 49] Complete (took 7ms)


Stephan 27 Aug 2013, 08:20:41

Aha. It's not a bug, it's a feature. Starting with 4.11 I think, the altTemplate is used ''only'' if you display the document that was explicitely requested in the url. If anything happens (404, redirect to login page...) then you're displaying another document, and we assume that the altTemplate should not apply.

That makes sense for 404 and almost every cases... except for internal redirect, for some users. So, there a config, which is not enabled by default. Look at config/umbracoSettings.config. Near the end there should be a <web.routing> section with an internalRedirectPreservesTemplate option that you want to set to true:

<web.routing internalRedirectPreservesTemplate="true"> </web.routing> And then... should work. Let me know!


Emil Rasmussen 27 Aug 2013, 09:17:03

Ahaha - that makes sense.

It does something differently, but it still doesn't work. See the following two log sequences (both with internalRedirectPreservesTemplate="true").

Log with umbracoInternalRedirectId property '''with''' a value:

2013-08-27 11:06:23,180 [47] DEBUG Umbraco.Web.UmbracoModule - [Thread 99] Begin request: http://umbraco.local/testtemplate/. 2013-08-27 11:06:23,181 [47] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 99] FindDomain: Uri="http://umbraco.local/testtemplate" 2013-08-27 11:06:23,181 [47] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 99] FindDomain: Matches no domain 2013-08-27 11:06:23,181 [47] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 99] FindDomain: Culture="en-US" 2013-08-27 11:06:23,181 [47] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 99] FindPublishedContentAndTemplate: Path="/testtemplate" 2013-08-27 11:06:23,181 [47] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 99] FindPublishedContent: Begin finders 2013-08-27 11:06:23,181 [47] DEBUG Umbraco.Web.Routing.ContentFinderByNiceUrl - [Thread 99] Test route "/testtemplate" 2013-08-27 11:06:23,181 [47] DEBUG Umbraco.Web.Routing.ContentFinderByNiceUrl - [Thread 99] No match. 2013-08-27 11:06:23,181 [47] DEBUG Umbraco.Web.Routing.ContentFinderByIdPath - [Thread 99] Not a node id 2013-08-27 11:06:23,181 [47] DEBUG Umbraco.Web.Routing.ContentFinderByNotFoundHandlers - [Thread 99] Running for legacy url='testtemplate'. 2013-08-27 11:06:23,181 [47] DEBUG Umbraco.Web.Routing.ContentFinderByNotFoundHandlers - [Thread 99] Handler 'umbraco.SearchForAlias'. 2013-08-27 11:06:23,181 [47] DEBUG Umbraco.Web.Routing.ContentFinderByNotFoundHandlers - [Thread 99] Replace handler 'umbraco.SearchForAlias' by new finder 'Umbraco.Web.Routing.ContentFinderByUrlAlias'. 2013-08-27 11:06:23,181 [47] DEBUG Umbraco.Web.Routing.ContentFinderByNotFoundHandlers - [Thread 99] Handler 'umbraco.SearchForTemplate'. 2013-08-27 11:06:23,181 [47] DEBUG Umbraco.Web.Routing.ContentFinderByNotFoundHandlers - [Thread 99] Replace handler 'umbraco.SearchForTemplate' by new finder 'Umbraco.Web.Routing.ContentFinderByNiceUrlAndTemplate'. 2013-08-27 11:06:23,187 [47] DEBUG Umbraco.Web.Routing.ContentFinderByNiceUrlAndTemplate - [Thread 99] Valid template: "testtemplate" 2013-08-27 11:06:23,187 [47] DEBUG Umbraco.Web.Routing.ContentFinderByNiceUrl - [Thread 99] Test route "/" 2013-08-27 11:06:23,188 [47] DEBUG Umbraco.Web.Routing.ContentFinderByNiceUrl - [Thread 99] Got content, id=1052 2013-08-27 11:06:23,189 [47] DEBUG Umbraco.Web.Routing.ContentFinderByNotFoundHandlers - [Thread 99] Finder 'Umbraco.Web.Routing.ContentFinderByNiceUrlAndTemplate' found node with id=1052. 2013-08-27 11:06:23,189 [47] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 99] FindPublishedContent: End finders, a document was found (took 8ms) 2013-08-27 11:06:23,189 [47] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 99] HandlePublishedContent: Begin 2013-08-27 11:06:23,189 [47] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 99] FollowInternalRedirects: Found umbracoInternalRedirectId=1053 2013-08-27 11:06:23,189 [47] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 99] FollowInternalRedirects: Redirecting to id=1053 2013-08-27 11:06:23,189 [47] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 99] EnsurePublishedContentAccess: Page is not protected 2013-08-27 11:06:23,189 [47] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 99] HandlePublishedContent: End 2013-08-27 11:06:23,189 [47] DEBUG Umbraco.Web.Routing.PublishedContentRequest - [Thread 99] FindTemplate: Has a template already, and no alternate template. 2013-08-27 11:06:23,189 [47] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 99] HandleWildcardDomains: Path="-1,1052,1053" 2013-08-27 11:06:23,189 [47] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 99] HandleWildcardDomains: No match. 2013-08-27 11:06:23,189 [47] DEBUG Umbraco.Web.UmbracoModule - [Thread 99] Response status: Redirect=none, Is404=false, StatusCode=0 2013-08-27 11:06:23,191 [47] WARN Umbraco.Web.Mvc.RenderMvcController - [Thread 99] No physical template file was found for template testtemplate 2013-08-27 11:06:23,191 [47] DEBUG Umbraco.Web.UmbracoModule - [Thread 99] Total milliseconds for umbraco request to process: 11.7132

Log with umbracoInternalRedirectId property '''without''' a value:

2013-08-27 11:07:12,075 [47] DEBUG Umbraco.Web.UmbracoModule - [Thread 9] Begin request: http://umbraco.local/testtemplate/. 2013-08-27 11:07:12,076 [47] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 9] FindDomain: Uri="http://umbraco.local/testtemplate" 2013-08-27 11:07:12,076 [47] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 9] FindDomain: Matches no domain 2013-08-27 11:07:12,076 [47] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 9] FindDomain: Culture="en-US" 2013-08-27 11:07:12,076 [47] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 9] FindPublishedContentAndTemplate: Path="/testtemplate" 2013-08-27 11:07:12,076 [47] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 9] FindPublishedContent: Begin finders 2013-08-27 11:07:12,076 [47] DEBUG Umbraco.Web.Routing.ContentFinderByNiceUrl - [Thread 9] Test route "/testtemplate" 2013-08-27 11:07:12,076 [47] DEBUG Umbraco.Web.Routing.ContentFinderByNiceUrl - [Thread 9] No match. 2013-08-27 11:07:12,076 [47] DEBUG Umbraco.Web.Routing.ContentFinderByIdPath - [Thread 9] Not a node id 2013-08-27 11:07:12,076 [47] DEBUG Umbraco.Web.Routing.ContentFinderByNotFoundHandlers - [Thread 9] Running for legacy url='testtemplate'. 2013-08-27 11:07:12,076 [47] DEBUG Umbraco.Web.Routing.ContentFinderByNotFoundHandlers - [Thread 9] Handler 'umbraco.SearchForAlias'. 2013-08-27 11:07:12,076 [47] DEBUG Umbraco.Web.Routing.ContentFinderByNotFoundHandlers - [Thread 9] Replace handler 'umbraco.SearchForAlias' by new finder 'Umbraco.Web.Routing.ContentFinderByUrlAlias'. 2013-08-27 11:07:12,076 [47] DEBUG Umbraco.Web.Routing.ContentFinderByNotFoundHandlers - [Thread 9] Handler 'umbraco.SearchForTemplate'. 2013-08-27 11:07:12,076 [47] DEBUG Umbraco.Web.Routing.ContentFinderByNotFoundHandlers - [Thread 9] Replace handler 'umbraco.SearchForTemplate' by new finder 'Umbraco.Web.Routing.ContentFinderByNiceUrlAndTemplate'. 2013-08-27 11:07:12,082 [47] DEBUG Umbraco.Web.Routing.ContentFinderByNiceUrlAndTemplate - [Thread 9] Valid template: "testtemplate" 2013-08-27 11:07:12,082 [47] DEBUG Umbraco.Web.Routing.ContentFinderByNiceUrl - [Thread 9] Test route "/" 2013-08-27 11:07:12,083 [47] DEBUG Umbraco.Web.Routing.ContentFinderByNiceUrl - [Thread 9] Got content, id=1052 2013-08-27 11:07:12,083 [47] DEBUG Umbraco.Web.Routing.ContentFinderByNotFoundHandlers - [Thread 9] Finder 'Umbraco.Web.Routing.ContentFinderByNiceUrlAndTemplate' found node with id=1052. 2013-08-27 11:07:12,083 [47] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 9] FindPublishedContent: End finders, a document was found (took 6ms) 2013-08-27 11:07:12,083 [47] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 9] HandlePublishedContent: Begin 2013-08-27 11:07:12,083 [47] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 9] EnsurePublishedContentAccess: Page is not protected 2013-08-27 11:07:12,083 [47] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 9] HandlePublishedContent: End 2013-08-27 11:07:12,083 [47] DEBUG Umbraco.Web.Routing.PublishedContentRequest - [Thread 9] FindTemplate: Has a template already, and no alternate template. 2013-08-27 11:07:12,083 [47] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 9] HandleWildcardDomains: Path="-1,1052" 2013-08-27 11:07:12,083 [47] DEBUG Umbraco.Web.Routing.PublishedContentRequestEngine - [Thread 9] HandleWildcardDomains: No match. 2013-08-27 11:07:12,083 [47] DEBUG Umbraco.Web.UmbracoModule - [Thread 9] Response status: Redirect=none, Is404=false, StatusCode=0 2013-08-27 11:07:12,099 [47] DEBUG umbraco.UmbracoDefault - [Thread 9] PreInit 2013-08-27 11:07:12,107 [47] DEBUG umbraco.UmbracoDefault - [Thread 9] Complete (took 8ms) 2013-08-27 11:07:12,126 [47] DEBUG umbraco.UmbracoDefault - [Thread 9] Init 2013-08-27 11:07:12,126 [47] DEBUG umbraco.UmbracoDefault - [Thread 9] Complete (took 0ms) 2013-08-27 11:07:12,127 [47] DEBUG umbraco.UmbracoDefault - [Thread 9] Load 2013-08-27 11:07:12,127 [47] DEBUG umbraco.UmbracoDefault - [Thread 9] Complete (took 0ms) 2013-08-27 11:07:12,132 [47] DEBUG umbraco.UmbracoDefault - [Thread 9] Render 2013-08-27 11:07:12,135 [47] DEBUG umbraco.UmbracoDefault - [Thread 9] Complete (took 2ms) 2013-08-27 11:07:12,135 [47] DEBUG Umbraco.Web.UmbracoModule - [Thread 9] Total milliseconds for umbraco request to process: 59.5421


Stephan 27 Aug 2013, 11:34:37

'''With''' a value: should display the redirected page (id=1053) with the "testtemplate" template. Actually that's what it is trying to do, but then (see the penultimate log line) it fails saying there's no physical file for "testtemplate". Does that template actually exist?

'''Without''' a value: should displays the home page (id=1052) with the "testtemplate" template. That's the normal behavior. The message ''Has a template already, and no alternate template'' is a bit misleading. What is it actually displaying?


Emil Rasmussen 27 Aug 2013, 11:47:04

'''With''' a value: Yes, it exists. It's exactly the same template that works in the example without a umbracoInternalRedirectId.

'''Without''' a value: The testtemplate is displayed, exactly as intended. So in this situation, it works!


Stephan 27 Aug 2013, 12:04:09

?!

So without the internal redirect, the "testtemplate" is used and everything is all right, but with the internal redirect, the "testtemplate" is detected by the pipeline (see line saying ''valid template'') but not by MVC?

That's an MVC template, right? What's the full path ie .../testtemplate.cshtml ?

Trying to repro here... stay tuned...


Emil Rasmussen 27 Aug 2013, 13:08:05

Yup. Without the internal redirect the "testtemplate" is used and all is good.

Nope, it's not a MVC template, its good old webforms, so the path is masterpages/testtemplate.master


Stephan 27 Aug 2013, 13:49:13

Oh... then obviously the MvcRenderController can't find the view since it's not an MVC view... but why would the controller run at all? There's only one reason I can think of... let me check...


Stephan 27 Aug 2013, 15:18:23

Think I got it. Silly bug on my part. Should push a fix soon, stay tuned.


Stephan 27 Aug 2013, 16:09:46

Fixed, commit da719377dfde1278dbb1d216aa89b7ec4a6588df in 6.2.0.


Stefan Kip 23 Feb 2016, 08:36:28

Thanks for the clarification @zpqrtbnk, setting internalRedirectPreservesTemplate to true did the trick for me :-)


Priority: Normal

Type: Bug

State: Fixed

Assignee:

Difficulty: Normal

Category: Architecture

Backwards Compatible: True

Fix Submitted:

Affected versions: 6.1.3, 6.1.4

Due in version: 6.1.5

Sprint:

Story Points:

Cycle: