I've added a node to the errors section in umbracoSettings.config, error403 to be exact. How can I read this value? I can't find any documentation on this.
Do you mean error404? or did you create your own custom error403 option?
If you are after the error404 values, you can get them by using this API call:
var errorPages = UmbracoConfig.For.UmbracoSettings().Content.Error404Collection;
If you've created a custom error403 value, then there is no strongly-typed way to access those values, you'll either need to use a traditional way of opening an XmlDocument and querying it; or using one of the legacy API calls, like this:
var nodes = umbraco.UmbracoSettings._umbracoSettings.SelectNodes("/settings/content/errors/error403");
I must warn you that with using the legacy APIs, it will probably be removed in future versions of Umbraco.
Get value from umbracoSettings.config
I've added a node to the errors section in umbracoSettings.config, error403 to be exact. How can I read this value? I can't find any documentation on this.
Hi Peter,
Do you mean
error404
? or did you create your own customerror403
option?If you are after the
error404
values, you can get them by using this API call:If you've created a custom
error403
value, then there is no strongly-typed way to access those values, you'll either need to use a traditional way of opening an XmlDocument and querying it; or using one of the legacy API calls, like this:I must warn you that with using the legacy APIs, it will probably be removed in future versions of Umbraco.
Good luck!
Cheers,
- Lee
I suppose you are right. I stored it in the AppSettings in web.config instead. Thanks for your reply!
What namespace do I need to include use this? (I want to get the 404 value from the umbracosettings.config file)
Is there an easy way to look this sort of thing up ?
Hi Karen,
The namespace is:
Cheers,
- Lee
Ah, I realize now that this is in v7 (found this thread via search and didn't look at what group it was).
I am in v6.2.1, so that is not working. Any ideas how to to it in v6 ? I can repost this question in the extending umbraco forums.
Hi - I just realized you presented the answer already - thanks!
is working on a reply...