1

我有一个 Web 服务文件,我正在尝试获取网站的 URL 以便将其传递给客户端。不幸的是,我收到错误“当前上下文中不存在名称‘请求’”。

这是代码:

string url = Request.Url.ToString().Substring(0, Request.Url.ToString().LastIndexOf("/")) + "CheckOut.aspx";

这是我在页面顶部的参考列表:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.Services;
using Newtonsoft.Json.Linq;
using Provider.Classes;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
using System.Text;

namespace Server
{
    public class VendorAppService : System.Web.Services.WebService
    {
        [WebMethod]
        public string StartPayment(string paymentDetails, byte[] signature)

有解决方法吗?谢谢你

更新

当我右键单击 Request 时,Visual Studio IDE 不会显示 Resolve 选项。

4

1 回答 1

2

请求在 WebServices 中不可用,您可以将其作为参数传递或将其设置在某个类的变量中并在此处访问它

于 2013-07-02T08:35:59.637 回答