Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null Exception when BaseUrl is empty #18

Open
natebunton opened this issue Apr 29, 2014 · 0 comments
Open

Null Exception when BaseUrl is empty #18

natebunton opened this issue Apr 29, 2014 · 0 comments

Comments

@natebunton
Copy link

When the BaseUrl site setting is empty a null exception is thrown in the AdvancedSitemapService.cs (Master) or HomeController.cs (Orchard-1.3x Tag v1.6.0).

    private string GetRootPath()
    {
        var baseUrl = _siteService.GetSiteSettings().BaseUrl;
        if (!baseUrl.EndsWith("/"))
            baseUrl += "/";
        return baseUrl;
    }

baseUrl should be checked for null or empty. if empty, then use ApplicationRootUrl (Orchard.Utility.Extensions)

    private string GetRootPath() {
        var baseUrl = _siteService.GetSiteSettings().BaseUrl;

        // If Base Url is not set, use the Request Application Root Url
        if (string.IsNullOrEmpty(baseUrl))
        {
            baseUrl = HttpContext.Request.ToApplicationRootUrlString();
        }

        if (!baseUrl.EndsWith("/"))
            baseUrl += "/";
        return baseUrl;
    }

I am using the Module from the Orchard Gallery, which looks like it is on branch Orchard-1.3x tag v1.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant