Estoy intentando migrar mi clases realizadas en MVC a NET.core 5 y tengo el siguiente problema al momento de utilizar HttpContext.Current.Request.PhysicalApplicationPath
y el Configuration.GetConnectionString
.
El mensaje que me devuelve al utilizar estas líneas es el siguiente: El nombre 'HttpContext' | 'Configuration' no existe en el contexto actual
He venido leyendo documentación pero no logro refactorizar para reescribir mi código en está nueva versión 5.
public void LogSistema(string Cadena, string Tipo)
{
try
{
string Log = Configuration.GetConnectionString("NombreLog");
string LogSistematxt = HttpContext.Current.Request.PhysicalApplicationPath + @"\" + Log + DateTime.Now.ToString("yyyyMMdd") + ".log";
if (!File.Exists(LogSistematxt))
{
using (StreamWriter sw = File.CreateText(LogSistematxt))
{
sw.WriteLine(Tipo + " " + DateTime.Now.ToString() + ":" + Cadena);
}
}
else
{
using (StreamWriter sw = File.AppendText(LogSistematxt))
{
sw.WriteLine(Tipo + " " + DateTime.Now.ToString() + ":" + Cadena);
}
}
}
catch (Exception)
{
throw;
}
}