UrlDecode() public method

public UrlDecode ( string s ) : string
s string
return string
Example #1
0
    public void Check_IsBlank()
    {
        string content = tools.CheckStr(Request["val"]);
        string success = tools.CheckStr(Server.UrlDecode(Request["success"]));

        if (success == "")
        {
            success = "信息输入正确!";
        }
        string error = tools.CheckStr(Server.UrlDecode(Request["error"]));

        if (error == "")
        {
            error = "信息不可为空!";
        }
        if (content == "")
        {
            Response.Write("<font color=\"#cc0000\">" + error + "</font>");
            return;
        }
        else
        {
            Response.Write("<font color=\"#00a226\">" + success + "</font>");
            return;
        }
    }
Example #2
0
        public static DataTable SerializePostToDataTable(System.Web.HttpRequest Request, System.Web.HttpServerUtility Server)
        {
            DataTable dTable = new DataTable();

            int iCount = Request.Form.Count;

            for (int i = 0; i < iCount; i++)
            {
                DataColumn Col = new DataColumn();
                Col.DataType   = System.Type.GetType("System.String");
                Col.ColumnName = Request.Form.GetKey(i).ToString();
                dTable.Columns.Add(Col);
            }

            DataRow Row = dTable.NewRow();

            foreach (DataColumn Col in dTable.Columns)
            {
                Row[Col.ColumnName] = Server.UrlDecode(Request[Col.ColumnName].ToString());
            }
            dTable.Rows.Add(Row);
            return(dTable);
        }
Example #3
0
 public override string UrlDecode(string s)
 {
     return(w.UrlDecode(s));
 }
    public Payline ECheckSale(string pCheckName, string pRoutingNumber, string pBnkAcNumber, string pAccountHolderType, string pAccountType, string pSecCode, string pPayment, Decimal pAmount, string pCurrency)
    {
        Payline payline = new Payline();


        System.Web.HttpServerUtility o = System.Web.HttpContext.Current.Server;
        string parmList = "";

        parmList = string.Format("username={0}&password={1}&type=sale&amount={2}&currency={3}&checkname={4}&checkaba={5}&checkaccount={6}&account_holder_type={7}&account_type={8}&sec_code=WEB&payment=check", ConfigurationSettings.AppSettings["PlGP:User"], ConfigurationSettings.AppSettings["PlGP:Pwd"], pAmount, pCurrency, pCheckName, pRoutingNumber, pBnkAcNumber, pAccountHolderType, pAccountType);

        payline.Request = parmList;

        // create and setup web request
        HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(System.Configuration.ConfigurationSettings.AppSettings["PlGP:HostAddress"]);

        webRequest.Method        = "POST";
        webRequest.ContentType   = "application/x-www-form-urlencoded";
        webRequest.ContentLength = parmList.Length;

        StreamWriter requestStream = null;

        try
        {
            requestStream = new StreamWriter(webRequest.GetRequestStream());
            requestStream.Write(parmList);
        }
        catch (Exception ex)
        {
            ErrorHandler("Error in GetAllApplicationData function .", ex.Message, ex.StackTrace);
        }
        finally
        {
            requestStream.Close();
        }

        HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();

        using (StreamReader responseStream = new StreamReader(webResponse.GetResponseStream()))
        {
            ResponseOut = o.UrlDecode(responseStream.ReadToEnd());
            responseStream.Close();
        }

        payline.Response = ResponseOut;

        string[] segments = ResponseOut.Split("&".ToCharArray());
        foreach (string segment in segments)
        {
            if (segment.StartsWith("response="))
            {
                payline.IsApproved = segment.Replace("response=", "").Trim().ToLower() == "1";
            }
            if (segment.StartsWith("responsetext="))
            {
                payline.Message = segment.Replace("responsetext=", "");
            }
            if (segment.StartsWith("authcode="))
            {
                payline.AuthorizationCode = segment.Replace("authcode=", "");
            }
            if (segment.StartsWith("transactionid="))
            {
                payline.AuthCaptureId = segment.Replace("transactionid=", "");
            }
            if (segment.StartsWith("TOKEN="))
            {
                payline.Token = segment.Replace("TOKEN=", "").Trim();
            }
            if (segment.ToUpper().StartsWith("PROFILEID="))
            {
                payline.ProfileId = segment.ToUpper().Replace("PROFILEID=", "").Trim();
            }
            if (segment.ToUpper().StartsWith("PAYERID="))
            {
                payline.PayerID = segment.ToUpper().Replace("PAYERID=", "").Trim();
            }
            if (segment.ToUpper().StartsWith("PAYERSTATUS="))
            {
                payline.PayerStatus = segment.ToUpper().Replace("PAYERSTATUS=", "").Trim();
            }
        }

        return(payline);
    }
    public Payline Sale(string firstName, string lastName, string accountNumber, string expirationMonth, string expirationYear, string securityCode, Decimal amount, string currency, string address1, int zip, string city, string state, string country)
    {
        Payline payline = new Payline();


        System.Web.HttpServerUtility o = System.Web.HttpContext.Current.Server;
        string parmList = "";

        parmList = string.Format("username={0}&password={1}&type=sale&ccnumber={2}&ccexp={3}{4}&cvv={5}&amount={6}&first_name={7}&last_name={8}&currency={9}&payment=creditcard&address1={10}&zip={11}&city={12}&state={13}&country={14}", ConfigurationSettings.AppSettings["PlGP:User"], ConfigurationSettings.AppSettings["PlGP:Pwd"], accountNumber, expirationMonth, expirationYear, securityCode, amount, firstName, lastName, currency, address1, zip, city, state, country);

        payline.Request = parmList;

        // create and setup web request
        HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(System.Configuration.ConfigurationSettings.AppSettings["PlGP:HostAddress"]);

        webRequest.Method        = "POST";
        webRequest.ContentType   = "application/x-www-form-urlencoded";
        webRequest.ContentLength = parmList.Length;

        StreamWriter requestStream = null;

        try
        {
            requestStream = new StreamWriter(webRequest.GetRequestStream());
            requestStream.Write(parmList);
        }
        catch (Exception ex)
        {
            ErrorHandler("Error in GetAllApplicationData function .", ex.Message, ex.StackTrace);
        }
        finally
        {
            requestStream.Close();
        }

        HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();

        using (StreamReader responseStream = new StreamReader(webResponse.GetResponseStream()))
        {
            ResponseOut = o.UrlDecode(responseStream.ReadToEnd());
            responseStream.Close();
        }

        payline.Response = ResponseOut;

        string[] segments = ResponseOut.Split("&".ToCharArray());
        foreach (string segment in segments)
        {
            if (segment.StartsWith("response="))
            {
                payline.IsApproved = segment.Replace("response=", "").Trim().ToLower() == "1";
            }
            if (segment.StartsWith("responsetext="))
            {
                payline.Message = segment.Replace("responsetext=", "");
            }
            if (segment.StartsWith("authcode="))
            {
                payline.AuthorizationCode = segment.Replace("authcode=", "");
            }
            if (segment.StartsWith("transactionid="))
            {
                payline.AuthCaptureId = segment.Replace("transactionid=", "");
            }
            if (segment.StartsWith("TOKEN="))
            {
                payline.Token = segment.Replace("TOKEN=", "").Trim();
            }
            if (segment.ToUpper().StartsWith("PROFILEID="))
            {
                payline.ProfileId = segment.ToUpper().Replace("PROFILEID=", "").Trim();
            }
            if (segment.ToUpper().StartsWith("PAYERID="))
            {
                payline.PayerID = segment.ToUpper().Replace("PAYERID=", "").Trim();
            }
            if (segment.ToUpper().StartsWith("PAYERSTATUS="))
            {
                payline.PayerStatus = segment.ToUpper().Replace("PAYERSTATUS=", "").Trim();
            }
        }

        return(payline);
    }
Example #6
0
 /// <summary>
 /// See <see cref="HttpServerUtility"/> for a description.
 /// </summary>
 public string UrlDecode(string s)
 {
     return(_httpServerUtility.UrlDecode(s));
 }
Example #7
0
        private IEnumerable<Cookie> GetCookies(HttpRequest httpRequest, HttpServerUtility server)
        {
            List<Cookie> tcookies = new List<Cookie>();

            if (httpRequest != null)
            {
                var cookies = httpRequest.Cookies;

                if (cookies != null)
                {
                    foreach (var key in cookies.AllKeys)
                    {
                        var cookie = cookies[key];

                        if (cookie != null)
                        {
                            tcookies.Add(
                             new Cookie
                           {
                               Name = cookie.Name,
                               Value = server.UrlDecode(cookie.Value),
                               Path = cookie.Path,
                               Domain = cookie.Domain
                           }
                            );


                        }
                    }
                }
            }
            return tcookies;
        }