Invalid Url matches Controller and View name and returns 500 instead of 404
Hi all, this sounds like a routing issue with Umbraco / MVC.
I have a multi-lingual site, and on one of the sites we are not permitted to have some types of content.
e.g.
www.abc.com/dashboard (this is permitted and page exists)
and
www.abc.com/gb/dashboard (this is not permitted and page does not exist)
The permitted dashboard url renders to a controlller named "dashboardController" and a view named "dashboard"
when I request www.abc.com/gb/dashboard which does not exist i do not get a 404 error instead I get a 500 server error that the model being passed to the dashboard view is incorrect.
I am presuming that this is because of the naming convention of the controller and view matching "dashboard"
is there anyway i can have Umbraco step in before MVC looks for a view and controller matching the url. At some level Umbraco is obvioulsy using this technique to match document types to the controllers and views
There was a function to force an Umbraco Content Page to load with a different template to the one it was published with - eg to provide an XML feed, or mobile view of the page (it was a long time ago).
To trigger this you added ?altTemplate=aliasOfTemplate to the Url to make this happen.
A convention was established that if, at the end of url you called a 'file' with the name of alias that would do the same job, eg /aliasOfTemplate.aspx
and then when 'everything went extensionless' the convention became just /aliasofTemplate
which is why you can get issues if the last portion of a url matches a valid template in Umbraco, it tries to load the page beneath with the template, (and in some versions of V7 even when that page doesn't exist).
If you don't rely on the altTemplate functionality in your site then you can turn it off!
in /config/umbracosettings.config
scrolll down right to the bottom to find the routing configuration:
(if you need the AltTemplate functionality in some circumstances, then you can leave it enabled and set validateAlternativeTemplates to be true, this will mean the template will only be loaded IF it's allowed to be displayed for the underlying node).
Invalid Url matches Controller and View name and returns 500 instead of 404
Hi all, this sounds like a routing issue with Umbraco / MVC.
I have a multi-lingual site, and on one of the sites we are not permitted to have some types of content.
e.g. www.abc.com/dashboard (this is permitted and page exists)
and
www.abc.com/gb/dashboard (this is not permitted and page does not exist)
The permitted dashboard url renders to a controlller named "dashboardController" and a view named "dashboard"
when I request www.abc.com/gb/dashboard which does not exist i do not get a 404 error instead I get a 500 server error that the model being passed to the dashboard view is incorrect.
I am presuming that this is because of the naming convention of the controller and view matching "dashboard"
is there anyway i can have Umbraco step in before MVC looks for a view and controller matching the url. At some level Umbraco is obvioulsy using this technique to match document types to the controllers and views
Hi David
There is a bit of history to this
'Back in the day'
There was a function to force an Umbraco Content Page to load with a different template to the one it was published with - eg to provide an XML feed, or mobile view of the page (it was a long time ago).
To trigger this you added ?altTemplate=aliasOfTemplate to the Url to make this happen.
A convention was established that if, at the end of url you called a 'file' with the name of alias that would do the same job, eg /aliasOfTemplate.aspx
and then when 'everything went extensionless' the convention became just /aliasofTemplate
which is why you can get issues if the last portion of a url matches a valid template in Umbraco, it tries to load the page beneath with the template, (and in some versions of V7 even when that page doesn't exist).
If you don't rely on the altTemplate functionality in your site then you can turn it off!
in /config/umbracosettings.config
scrolll down right to the bottom to find the routing configuration:
and set disableAlternativeTemplates to be 'true'
(if you need the AltTemplate functionality in some circumstances, then you can leave it enabled and set validateAlternativeTemplates to be true, this will mean the template will only be loaded IF it's allowed to be displayed for the underlying node).
regards
Marc
is working on a reply...