簡體   English   中英

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

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

在我們使用 .net 5 之前,我們使用 .net 框架。

// 網絡框架

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

//

但現在我們使用 .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