简体   繁体   English

如何在 .net core 5 中使用 HttpContext.Current(无 necromenssing)

[英]how to use HttpContext.Current in net core 5 (no necromenssing)

before we use.net 5 we use.net framework.在我们使用 .net 5 之前,我们使用 .net 框架。

// Net Framework // 网络框架

ClsLog.WriteLog(HttpContex.Current, GetType(), "GetManualWeightData", ActionType.Action_Read, model.UID, model, clsResponse, clsResponse.ErrorMsg, model.LogCode);

// //

but now we use.net 5 and.net 5 cant use current... how to instaed of "current"?但现在我们使用 .net 5 和 .net 5 不能使用电流...如何取代“电流”?

+ +


 public class ClsLog
    {
        public static void WriteLog(HttpContext current, Type type, string strMethodName, string strActionType, string strUID, object strParam, object strResponse, string strErrorMsg = "", string strLogCode = "")
        {
            string strLocalIP = "";
            string strBrowser = "";
            string strMemID = "";
            string strCustomerID = "";

            if (current != null)
            {
                //strLocalIP = current.Session("LocalIP"] + "";
                //strBrowser = current.Session["BrowserInfo"] + "";
                //strMemID = current.Session["LogID"] + "";
                //strCustomerID = current.Session["CustomerID"] + "";
            }
            try
            {
                Task.Run(() => ClsWriteLog.getInstance().WriteLogServer(new ClsVariableAppLog("AppAPILog", strLocalIP, strBrowser, strMemID, strCustomerID, type.Module.Name, strMethodName, strUID, strActionType, type.FullName, strErrorMsg, strParam, strResponse, strLogCode)));
                //await ClsWriteLog.getInstance().WriteLogServer(new ClsVariableAppLog("AppAPILog", strLocalIP, strBrowser, strMemID, strCustomerID, type.Module.Name, strMethodName, strUID, strActionType, type.FullName, strErrorMsg, strParam, strResponse));
            }
            catch (Exception ex)
            {
                Trace.WriteLine("LogError - " + ex.Message);
            }
        }
}```

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM