Reputation: 885
I have a web service file and I am trying to get the URL of the website in order to pass it to the client. Unfortunately, I am getting the error "The name 'Request' does not exist in the current context".
This is the code:
string url = Request.Url.ToString().Substring(0, Request.Url.ToString().LastIndexOf("/")) + "CheckOut.aspx";
This is my list of references at the top of the page:
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)
Is there a workaround around this? thank you
Update
When I right-click on Request, the Visual Studio IDE does not bring up the Resolve option.
Upvotes: 1
Views: 8221
Reputation: 613
Request is not available in WebServices, you can pass it as an argument or set it in a variable in some class and access it here
Upvotes: 2