This helper class is used in ASP.NET Core web apps to get paths, URLs, query values, and client details.
public class HomeController : Controller
{
public IActionResult Index()
{
var web = new Web4(HttpContext);
string appUrl = web.GetAppUrl();
string pageUrl = web.GetPageUrl();
string clientIp = web.GetClientIP();
string tempFolder = web.TempPath;
return Content($"App URL: {appUrl}
Page URL: {pageUrl}
IP: {clientIp}");
}
}
The constructor auto-creates required folders inside the app root: