如何在ASP.NET Core中獲取HttpContext.Current?我們目前正在使用ASP.NET Core重寫/轉(zhuǎn)換我們的ASP.NET WebForms應(yīng)用程序。盡量避免重新設(shè)計(jì)。我們HttpContext在類庫中使用了一個(gè)部分來檢查當(dāng)前狀態(tài)。如何HttpContext.Current在.NET Core 1.0中訪問? var current = HttpContext.Current;
if (current == null)
{
// do something here
// string connection = Configuration.GetConnectionString("MyDb");
}我需要訪問它才能構(gòu)建當(dāng)前的應(yīng)用程序主機(jī)。$"{current.Request.Url.Scheme}://{current.Request.Url.Host}{(current.Request.Url.Port == 80 ? "" : ":" + current.Request.Url.Port)}";
如何在ASP.NET Core中獲取HttpContext.Current?
婷婷同學(xué)_
2019-08-16 16:04:04