"Name does not exist in current context"

I get the following error; The name "Request" does not exist in the current context

using System;
using System.Web;
using System.Web.UI;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using Microsoft.Exchange.WebServices.Data;

namespace Exchange101
{
    // This sample is for demonstration purposes only. Before you run this sample, make sure that the code meets the coding requirements of your organization.
    class Ex15_CreateMeetingOnBehalfOfPrinciple_CS
    {
        static ExchangeService service = Service.ConnectToService(UserDataFromConsole.GetUserData(), new TraceListener());
        protected void Page_Load(object sender, EventArgs e)
        {
            var request = HttpContext.Current.Request.QueryString["source"];
            HttpRequest q = Request;
            NameValueCollection n = q.QueryString;
            if (n.HasKeys())
            {
                string k = n.GetKey(0);
                if (k == "one")
                {
                    string v = n.Get(0);
                }
                if (k == "two")
                {
                    string v = n.Get(0);
                }
            }
        }

I am an absolute newbie and have researched the error, but I am confused about which assembly I might lose as a reference.

+4
source share
3 answers
Question

maybe here

 var request = HttpContext.Current.Request.QueryString["source"];
 HttpRequest q = Request;

your variable name is query . bt you are using Request

change it like

 var request = HttpContext.Current.Request.QueryString["source"];
 HttpRequest q = Request;

this will help solve your problem

+4
source

Change this line:

class Ex15_CreateMeetingOnBehalfOfPrinciple_CS

:

class Ex15_CreateMeetingOnBehalfOfPrinciple_CS : System.Web.UI.Page

It seems that the problems you are getting are properties that you should inherit from this class.

0
source

HttpWebRequest,    System.Net;

-1

Source: https://habr.com/ru/post/1534576/


All Articles