Last active
October 4, 2021 13:30
-
-
Save eduardocp/61daae2ee0af6a40bda3c4d4a6489a15 to your computer and use it in GitHub Desktop.
HttpContext on .net core
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Microsoft.AspNetCore.Hosting; | |
| using Microsoft.AspNetCore.Http; | |
| using System.IO; | |
| namespace System.Web | |
| { | |
| public static class HttpContext | |
| { | |
| private static IHttpContextAccessor _context; | |
| private static IWebHostEnvironment _hostingEnvironment; | |
| public static void Configure(IHttpContextAccessor httpContextAccessor, IWebHostEnvironment hostingEnvironment) | |
| { | |
| _context = httpContextAccessor; | |
| _hostingEnvironment = hostingEnvironment; | |
| } | |
| public static Microsoft.AspNetCore.Http.HttpContext Current => _context?.HttpContext; | |
| public static string MapPath(string path) | |
| { | |
| return Path.Combine(_hostingEnvironment.ContentRootPath, path); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment