I have setup 404 redirection successfully for an umbraco project. If the user navigates to a page that doesn't exist it shows the designated node id.
However consider this:
http://tsw/course-calendar/ - Correct Link
http://tsw/coursecalendar/ - Doesn't 404 (but should)
http://tsw/coursecalenda/ - 404 redirects
In the example above the correct link as per umbraco is the second however if I remove the dash but leave the words I get a Server error:
The model item passed into the dictionary is of type 'Castle.Proxies.HomepageDTProxy', but this dictionary requires a model item of type 'TSW.Web.ViewModels.CourseCalendarVM'.
It's like the page is trying to resolve the URL.
How do I stop this behaviour in Umbraco so that only full and accurate links are opened and the remaining are 404 redirected?
Do you have a doctype or template named coursecalendar? Then that might be it. If so, there are options to disable the URL resolving, see https://our.umbraco.com/forum/templates-partial-views-and-macros/ . The "switch" is disableAlternativeTemplates in umbracoSettings.config
Related
Whenever we try to add a link using any of the link types (including media links), we get the empty Sitecore Items tree in the dialog window:
Link Selector Dialog
The tree list only shows the top level /sitecore and nothing else. Are we missing a configuration somewhere or is this a bug that needs to get reported?
If there are no errors in the console then you receive a successful response with 200 status, but empty item[] in JSON response. So, this is a matter of configuration. Please check the template of your item and make sure that you have specified the correct data source for the link field. In case if the data source path is invalid or empty you will get the empty tree.
This issue stemmed from a pipeline patch that was created to catch Glass Mapper generated processor errors. Once removed we had the tree list populating as it should.
I am new to Umbraco CMS. I have every thing setup but get the following error. (Highlighted in red.)
How do I set the URLs in Umbraco. Or fix them?
The alias (short URL) of a page is defined by the name that you give the page in the input bar at the top of the page:
If you have two pages both named Weddings, then they will conflict; you can only access one view when visiting /weddings/.
In order to correct this, simply come up with unique names for your pages, such as Indoor Weddings and Outdoor Weddings (for example).
While these page names are mostly for organisation within the Umbraco CMS, they will be reflected in in URL, so I would recommend choosing something semantic.
Note that you can also set the page's URL manually with the UmbracoUrlName (and UmbracoUrlAlias) routing property if need be.
I'm running a simple site based on Joomla. The SEF URLs are defined by SH404SEF and look like https://[domain]/[category]/[sub category]/[article title alias].html. In some cases there is a 1-to-1 relationship between category and article but in some cases one category has several articles.
Suddenly I have URLs requested following https://[domain]/table/[category]/[sub category]/. Not only does these new URLs in some cases create 404s, they also view my articles in the wrong way and when there is not a 1-to-1 relationship between category and article the link adds several articles on one page.
The correct non-SEF URL ends with &view=article and the new, uncorrect non-SEF URL ends with &view=category. I have no table/ in my correct URLs, neither in any internal link, in the articles' html code, in menu items nor in my sitemap.xml. I've discussed this with the few extension providers I am using and none of them see their extension as doing this request new.
Is there any way to find out what is making these requests?
I cannot make a redirect for these URLs since all of them do not
correspond to one article, but several. Can you see any risk with
making a rewrite rule that puts a 410 on all URLs that starts with
table/?
This is actually a misconfiugration in sh404SEF. Here's what to do:
Login to the backend of your Joomla site
Go to the sh404SEF configuration
Set the field "Insert Content Table Name" to "No"
Flush all URLs and clear your Joomla cache
This should do it.
I've got a WebFilter that redirects to the login page in my application. In order to redirect back to the referring page I've also added a view parameter called redirectOnLogin which is then used on successful logins in order to perform the final navigation.
If one were to manipulate this query parameter, one could easily provoke JSF navigation errors. I would therefore like to pre-empt this by checking that the outcome is valid but I've not been able to uncover a mechanism for pre-validating a JSF outcome.
Easiest and best is to make sure the redirectToLogin parameter cannot be manipulated. Or that manipulation is detected.
You could solve this in (at least) two ways
Taking the original page name, adding a 'salt' to it and creating a hash.
Addin this has that in the request to the login server
Make sure it is returned by the login server (maybe adding it as # to the return page or as a param.
On receiving it on the 'redirectOnLogin' page, use the page name, the same salt and create a hash in the same way. Compare these and if they match you are fine, if they don't throw an error.
Or you could
Store the 'redirectOnLogin' page in a session to
Check on returning from the login server if it matches with the page you end-up on.
I have seen in umbraco code, where developers get reference to a content page, like this:
var content = UmbracoContext.PublishedContentRequest.IsInternalRedirectPublishedContent
? UmbracoContext.PublishedContentRequest.InitialPublishedContent
: UmbracoContext.PublishedContentRequest.PublishedContent;
BUT why do they do that ?
Why not use # Model.Content ()
What is (What do they do):
IsInternalRedirectPublishedContent?
InitialPublishedContent ?
PublishedContent ?
In Umbraco there's a bunch of reserved properties you can put on documents to get some "hidden" functionality. One of them is umbracoInternalRedirectId which allows you to do an internal redirect and render another node instead of the node being requested.
You can read more about some of those other reserved properties here.
In case you use the internal redirect, your request will internally be redirected to another node ID and then everything will be rendered as if you had initially requested that other node (you will however not see a browser redirect and it will not be reflected in the URL either).
What is (What do they do):
IsInternalRedirectPublishedContent?
This will be true if the content you are redirecting to, is currently published. False if the content is unpublished.
InitialPublishedContent ?
This will be the content item you are initially hitting (before the redirect happens).
PublishedContent ?
This will be the content item you are redirected to (this will be the same as the current content item you mention above).
BUT why do they do that ?
What is done above is to try to always get a reference to the initial content before any internal redirect happening in case of a redirect - and to just get the current content item if there's no internal redirect happening.
It however doesn't really seem to make sense to do this, considering that in case of IsInternalRedirectPublishedContent returning false, InitialPublishedContent will be the same as PublishedContent.
You would get the same result as above by simply doing:
var content = UmbracoContext.PublishedContentRequest.InitialPublishedContent;
It may however be that this has not always been the case and that this piece of code was to work around a bug in an older version of Umbraco.
So I'd say unless you have a very strange redirect setup in your site, there should be no reason for not just using this piece of code instead of the one you posted.
To completely answer your question:
In the code above, using content in your template, would be a reference to the page where the redirect is configured at. Using Model.Content would be a reference to the node your are internally redirected to.