c# - C# 中的服务器托管错误

标签 c#

我使用 ASP.Net 3.5 和 C# 开发了一个电子商务网站。它在 Visual Stdio 2010 中运行良好。我将我的网站上传到我的域中的公用文件夹下。 它显示如下错误:Local and server-side errors

点击查看全尺寸,或者这里是来自本地错误页面的堆栈跟踪片段。

NullReferenceException: Object reference not set to an instance of an object
SageFrame.Framework.PageBase.OptimizeJs(List`1 lstJsColl, Int32 Mode) +7940
SageFrame.Framework.PageBase.LoadModuleJs() +944
SageFrame.Framework.PageBase.OnPreRender(EventArgs e) +233
System.Web.UI.PreRenderRecursiveInternal() +107

它之前工作正常!

page_Load() 的代码是:

protected void Page_Load(object sender, EventArgs e)
    {
        string selectedCurrency = string.Empty;
        string MainCurrency = string.Empty;
        try
        {
            StoreSettingConfig ssc = new StoreSettingConfig();
            MainCurrency = ssc.GetStoreSettingsByKey(StoreSetting.MainCurrency, GetStoreID, GetPortalID, GetCurrentCultureName);
            if (Session["SelectedCurrency"] != null && Session["SelectedCurrency"] != "")
            {
                selectedCurrency = Session["SelectedCurrency"].ToString();
            }
            else
            {
                selectedCurrency = MainCurrency;
            } 

            string islive = Request.Form["custom"];
            string test = string.Empty;
            const string strSandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr";
            const string strLive = "https://www.paypal.com/cgi-bin/webscr";
            test = bool.Parse(islive.Split('#')[6]) ? strSandbox : strLive;

            var req = (HttpWebRequest)WebRequest.Create(test);
            //Set values for the request back
            req.Method = "POST";
            req.ContentType = "application/x-www-form-urlencoded";
            byte[] param = Request.BinaryRead(HttpContext.Current.Request.ContentLength);
            string strRequest = Encoding.ASCII.GetString(param);
            strRequest += "&cmd=_notify-validate";
            req.ContentLength = strRequest.Length;
            var streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
            streamOut.Write(strRequest);
            streamOut.Close();
            var streamIn = new StreamReader(req.GetResponse().GetResponseStream());
            string strResponse = streamIn.ReadToEnd();
            streamIn.Close();            
            if (strResponse == "VERIFIED")
            {
                string payerEmail = Request.Form["payer_email"];
                string paymentStatus = Request.Form["payment_status"];
                string receiverEmail = Request.Form["receiver_email"];
                string amount = Request.Form["mc_gross"];
                string invoice = Request.Form["invoice"];
                string addressName = Request.Form["address_name"];
                string addressStreet = Request.Form["address_street"];
                string addressCity = Request.Form["address_city"];
                string addressZip = Request.Form["address_zip"];
                string addressCountry = Request.Form["address_country"];
                string transID = Request.Form["txn_id"];
                string custom = Request.Form["custom"];

                string[] ids = custom.Split('#');
                int orderID = int.Parse(ids[0]);
                int storeID = int.Parse(ids[1]);
                int portalID = int.Parse(ids[2]);
                string userName = ids[3];
                int customerID = int.Parse(ids[4]);
                string sessionCode = ids[5];
                string pgid = ids[7];

                var tinfo = new TransactionLogInfo();
                var tlog = new TransactionLog();

                tinfo.TransactionID = transID;
                tinfo.AuthCode = "";
                tinfo.TotalAmount = decimal.Parse(amount);
                tinfo.ResponseCode = "1";
                tinfo.ResponseReasonText = "";
                tinfo.OrderID = orderID;
                tinfo.StoreID = storeID;
                tinfo.PortalID = portalID;
                tinfo.AddedBy = userName;
                tinfo.CustomerID = customerID;
                tinfo.SessionCode = sessionCode;
                tinfo.PaymentGatewayID = int.Parse(pgid);
                tinfo.PaymentStatus = paymentStatus;
                tinfo.PayerEmail = payerEmail;
                tinfo.CreditCard = "";
                tinfo.RecieverEmail = receiverEmail;
                tinfo.CurrencyCode = selectedCurrency;
                tlog.SaveTransactionLog(tinfo);


                if (paymentStatus.Equals("Completed"))
                {                    
                    var paypalobj = new PayPalHandler();
                    paypalobj.ParseIPN(orderID, transID, paymentStatus, storeID, portalID, userName, customerID, sessionCode);
                }


            }
            else if (strResponse == "INVALID")
            {
                //log for manual investigation
            }
            else
            {
                //log response/ipn data for manual investigation
            }
            // }
        }
        catch (Exception ex)
        {
            ProcessException(ex);
          //  throw new Exception("This Page is not accessible!");
        }
    }

最佳答案

从错误消息来看,似乎无法加载您的商店库。这可能是因为它未安装在服务器上或信任级别太低。

无论哪种方式,您的托管服务提供商都可以协助进行设置。

关于c# - C# 中的服务器托管错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16605212/

相关文章:

c# - 为什么是 RestSharp AddHeader ("Accept", "application/json"); = 到项目列表?

c# - C# 中的平滑视频渲染

c# - 如何在 C# 中只获取字符串中的字母?

c# - 使用Prism 4的完整示例应用程序

c# - 从具有共同值的字典中获取 TKey,其中 TValue 是 List<string>

c# - Visual Studio 2010 —选择的解决方案配置会影响批量生成的输出

C# MySQL - 从特定列检索数据并插入变量

c# - 使用 Swagger 的特定状态代码的响应模型

c# - C# 中的线程导致无限循环并阻止我的应用程序

c# - 如果 NodaTime 使用 Duration 而 Postgres 使用 INTERVAL/Period,如何在 EF Core 中进行时间戳运算?