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

v8-9: Replace Server.MapPath #9

Closed
LottePitcher opened this issue Nov 16, 2021 · 0 comments
Closed

v8-9: Replace Server.MapPath #9

LottePitcher opened this issue Nov 16, 2021 · 0 comments

Comments

@LottePitcher
Copy link
Member

LottePitcher commented Nov 16, 2021

v8

var appDataFolder = UmbracoContext.HttpContext.Server.MapPath("~/App_Data");

v9

The App_Data folder is no longer a special 'protected' folder. Steps can be taken to ensure that all its contents is protected, but for our purposes we actually don't need it to be protected. So we chose a different folder name to avoid future confusion about whether App_Data is actually protected or not.

public class GuestbookApiController : UmbracoApiController
{
    private readonly IWebHostEnvironment _webHostEnvironment;

    public GuestbookApiController(IWebHostEnvironment webHostEnvironment)
    {
        _webHostEnvironment = webHostEnvironment;
    }

    public string GetEntries(string id)
    {
       var githubFolder = _webHostEnvironment.ContentRootPath + "\\wwwroot\\github";
    }
}

PS we know it is good practice to create paths using Path.Combine instead of the approach above. Something else to do ;-)

@LottePitcher LottePitcher changed the title Replace Server.MapPath v8-9: Replace Server.MapPath Nov 16, 2021
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