I'm using Umbraco 4.9.0 and I want to redirect some nodes without template to the 404 error page. To do that, I've assigned a template that makes a redirection to the 404 node.
To make the redirection I use
HttpContext.Current.Response.StatusCode = 404;
HttpContext.Current.Response.Redirect(redirectPath, false);
What it actually does is a first 302 redirection and then a 404, which is not what I'm actually looking for.
I'd like to know if there is a way to call the default 404 umbraco redirection, the one which is automatically executed when someone tries to access to a non-existing node.
I'm using Umbraco 4.9.0. In this version, pages without template trigger a very ugly error, not a 404.
I know that in later versions it's fixed triggering a 404, but not in 4.9.0. In most forums recommend to create an "Error template" to assign to nodes without template.
In my code I have a custom 404 handler as the links say, and it works perfectly when a 404 is triggered. The problem is that I need to fire a 404 event manually, and I don't have any idea on how :(
You only have a "default" id page for all errors, but it's similar as what I have.
What version of Umbraco are you using?
If you use 4.9 or below, I don't believe pages without template trigger 404 in your computer. It was a "bug" of Umbraco and, as far as I know, it was solved in 4.10.
If it works on your computer, please let me know how... :)
That's actually what I have in my code, and it's used to decide which error page must be shown depending on the culture. But this doesn't trigger any 404 error page, this is executed when the "404 error page event" is fired.
Could you tell me what you have in your /config/404handlers.config file, please?
That was the only way I found to render another page without using "Server.Transfer", which doesn't work in Umbraco, and without changing the URL using Response.Redirect.
Force 404 redirection from another node
Hi,
I'm using Umbraco 4.9.0 and I want to redirect some nodes without template to the 404 error page. To do that, I've assigned a template that makes a redirection to the 404 node.
To make the redirection I use
HttpContext.Current.Response.StatusCode = 404; HttpContext.Current.Response.Redirect(redirectPath, false);
What it actually does is a first 302 redirection and then a 404, which is not what I'm actually looking for.
I'd like to know if there is a way to call the default 404 umbraco redirection, the one which is automatically executed when someone tries to access to a non-existing node.
Thanks in advance,
Have a look at 404 handlers. This will allow you to do just that without redirects
http://our.umbraco.org/wiki/install-and-setup/configuring-404-pages
http://our.umbraco.org/wiki/reference/files-and-folders/files-in-the-config-folder/404handlersconfig
http://our.umbraco.org/wiki/how-tos/how-to-implement-your-own-404-handler
Dave
Hi Dave, thanks for replying.
These handlers fire automatically when a page is not found. I want to simulate that a page is not found even it exists, so I want to fire it manually.
Do you hve any idea on how?
Thanks!
If you configure these. Also pages without a template assigned should trigger a 404
Dave
I'm using Umbraco 4.9.0. In this version, pages without template trigger a very ugly error, not a 404.
I know that in later versions it's fixed triggering a 404, but not in 4.9.0. In most forums recommend to create an "Error template" to assign to nodes without template.
In my code I have a custom 404 handler as the links say, and it works perfectly when a 404 is triggered. The problem is that I need to fire a 404 event manually, and I don't have any idea on how :(
You can set a the id of a page in the umbracosettings.config that will show when a page without a template is called.
Yo know where?
I have:
Where can I set the id you said?
I don't have a specific culture setup
I have it like this :
<errors>
<error404>myid</error404>
</errors>
You only have a "default" id page for all errors, but it's similar as what I have.
What version of Umbraco are you using? If you use 4.9 or below, I don't believe pages without template trigger 404 in your computer. It was a "bug" of Umbraco and, as far as I know, it was solved in 4.10.
If it works on your computer, please let me know how... :)
I have this setup on 4.7.2 and it works there
Can't you do a upgrade instead of find a workaround ?
Dave
I can't upgrade it. I need this version for the moment :( I'll try it again, but I don't understand how it works in 4.7.2!
Thanks anyway! Jordi
Maybe the error is related to setting error pages per culture ? Because I don't have a culture set and it works.
Dave
Another option ofcourse is create your own 404 handler with the bug fixed. You can get the source of the lastest version here.
https://github.com/umbraco/Umbraco-CMS/blob/e41d3c7e844b63780a4842ccd105e8bb593e4d54/src/Umbraco.Web/umbraco.presentation/NotFoundHandlers.cs
Dave
That's actually what I have in my code, and it's used to decide which error page must be shown depending on the culture. But this doesn't trigger any 404 error page, this is executed when the "404 error page event" is fired.
Could you tell me what you have in your /config/404handlers.config file, please?
My 404config is the default one?
Maybe you can post your config and code ?
This is my file:
<?xml version="1.0" encoding="utf-8"?>
<NotFoundHandlers>
<notFound assembly="InfoCaster.Umbraco._301UrlTracker" type="Handler301URLTracker" />
<notFound assembly="umbraco" type="SearchForAlias" />
<notFound assembly="umbraco" type="SearchForProfile" />
<notFound assembly="UmbracoExtensions" type="Custom404" />
</NotFoundHandlers>
I don't see your file content
sorry!
Can you post the code of your file handler ?
I finally solved my problem. I created a function that simulates the 404 error. I did it by doing the following:
That was the only way I found to render another page without using "Server.Transfer", which doesn't work in Umbraco, and without changing the URL using Response.Redirect.
I hope this helps!
is working on a reply...