Server.MapPath C#在本地工作,但不在实时服务器上工作

时间:2017-10-16 12:16:36

标签: c# asp.net

enter image description here与Server.MapPath存在很大问题,我无法从服务器解析它。 我在文件夹中获取证书文件,在本地,它以各种不同的方式工作正常,但是当我把它放到服务器时它显示错误“找不到指定的文件路径”

.aspx.cs文件中的MyCode:

  var certificatePath = HttpContext.Current.Server.MapPath("~/Push/testkeys/Certificates.p12");

var push = new PushNotification(true,certificatePath,“mobile”);

.cs文件:

public PushNotification(bool useSandbox, string p12File, string p12FilePassword)
    {
        if (useSandbox)
        {
            _host = SandboxHost;
            _feedbackHost = SandboxFeedbackHost;
        }
        else
        {
            _host = ProductionHost;
            _feedbackHost = ProductionFeedbackHost;
        }
        _certificate = new X509Certificate2(p12File, p12FilePassword, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable);

        _certificates = new System.Security.Cryptography.X509Certificates.X509CertificateCollection { _certificate };

        // Loading Apple error response list.
        _errorList.Add(0, "No errors encountered");
        _errorList.Add(1, "Processing error");
        _errorList.Add(2, "Missing device token");
        _errorList.Add(3, "Missing topic");
        _errorList.Add(4, "Missing payload");
        _errorList.Add(5, "Invalid token size");
        _errorList.Add(6, "Invalid topic size");
        _errorList.Add(7, "Invalid payload size");
        _errorList.Add(8, "Invalid token");
        _errorList.Add(255, "None (unknown)");
    }

0 个答案:

没有答案