我有一个客户端应用程序,它将调用 Web 方法并传递两个值(订单和金额)。Web 方法将设置 Session/Cookie 中的值。现在客户端应用程序将重定向到其他网站,该网站应该能够通过 Session/Cookie 获取订单和金额值。由于安全问题,我不能将其用作查询字符串。请帮助我找到适当的解决方案。Web服务中的代码如下:
[WebMethod(EnableSession = true,Description="SetValues")]
public void CallService(string orderNumber, double amount)
{
if (orderNumber != null && orderNumber != string.Empty)
{
Context.Session["OrderID"] = orderNumber;
Context.Session["Amount"] = amount; //Tried Session but did no work
//Tried Setting the value in Cookie
HttpCookie OrderID = new HttpCookie("OrderID",orderNumber);
HttpCookie Amount = new HttpCookie("Amount", amount.ToString());
OrderID.Expires = DateTime.Now.AddHours(3);
Amount.Expires = DateTime.Now.AddHours(3);
Context.Response.SetCookie(Amount);
Context.Response.SetCookie(OrderID);
}
}
//从Cookie中获取值的代码
Service.ServiceAPISoapClient e1 = new Service.ServiceAPISoapClient();
e1.CallEISService("12e", 121);
string amount= Request.Cookies["Amount"] != null? Request.Cookies["Amount"].Value:"";