UmbracoContext.Application.Services.ContentService.GetRootContent() is not the right answer.
I want a error404 redirect on requested Servername.
Heres my Code:
public bool Execute(string url) { var server = HttpContext.Current.Request.ServerVariables["SERVER_NAME"].ToLower(); //Doesn`t work in V7 var rootNodeId = Domain.GetRootFromDomain(server);
if (rootNodeId == -1) return false;
// redirect to error404 page var errorPage = ConfigurationService.Instance.GetError404(rootNodeId).Url; HttpContext.Current.Response.Redirect(errorPage, true);
Sorry to bump a really old topic, but I'm running into this same problem where "Domain" from "umbraco.cms.businesslogic" has been marked obsolete and I need to fix it in Umbraco 7.5.8.
Has anyone solved this?
The error notes this, but I'm not sure how I can use either one of these interfaces to access the same method.
'Domain' is obsolete: 'Use Umbraco.Core.Models.IDomain and Umbraco.Core.Services.IDomainService instead'
Here's what I see when I look at the source of the method you shouldn't use any more:
public static int GetRootFromDomain(string DomainName)
{
var found = ApplicationContext.Current.Services.DomainService.GetByName(DomainName);
return found == null ? -1 : found.RootContentId ?? -1;
}
Alternative to Domain.GetRootFromDomain() ?
Hi,
does anybody know an alternative to Domain.GetRootFromDomain() ?
Hi PRK,
You can use one of this methods to get root nodes:
CurrentPage.AncestorOrSelf(1) or UmbracoContext.Application.Services.ContentService.GetRootContent()
Thanks, Alex
What's wrong with Domain.GetRootFromDomain()?
Hi all,
thanks for your answers.
@Sebastian:
Nothing wrong with Domain.GetRootFromDomain(). But I can`t find it in Umbraco V7.
@Alex:
Thanks, I haven not seen that (UmbracoContext.Application.Services.ContentService.GetRootContent()).
Okay,
UmbracoContext.Application.Services.ContentService.GetRootContent() is not the right answer.
I want a error404 redirect on requested Servername.
Heres my Code:
{
var server = HttpContext.Current.Request.ServerVariables["SERVER_NAME"].ToLower(); //Doesn`t work in V7
var rootNodeId = Domain.GetRootFromDomain(server);
if (rootNodeId == -1) return false;
// redirect to error404 page
var errorPage = ConfigurationService.Instance.GetError404(rootNodeId).Url;
HttpContext.Current.Response.Redirect(errorPage, true);
return true;
}
This works perfectly in 7.0.3?
Maybe you're just missing the namespace.
I don`t know why, but I have to reference umbraco.cms several times in vs20130 before it worked.
Rookie error :-)
Sorry to bump a really old topic, but I'm running into this same problem where "Domain" from "umbraco.cms.businesslogic" has been marked obsolete and I need to fix it in Umbraco 7.5.8.
Has anyone solved this?
The error notes this, but I'm not sure how I can use either one of these interfaces to access the same method.
Did you know that open source is awesome? ;-)))
Here's what I see when I look at the source of the method you shouldn't use any more:
That's killer; thank you! I hadn't thought to look at the source code.
is working on a reply...