简体   繁体   English

“该名称在当前上下文中不存在”

[英]“The name does not exist in the 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'm an absolute newbie and have researched the error but am confused as to which assembly I might be missing as a reference. 我是一个绝对的新手并且已经研究过这个错误但是对于我可能缺少哪个程序集作为参考感到困惑。

issue may be here 问题可能在这里

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

your variable name is request bt you are using Request 你的变量名是请求你正在使用请求

change this as 将此更改为

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

this wil solve your issue 这将解决你的问题

Change this line: 改变这一行:

class Ex15_CreateMeetingOnBehalfOfPrinciple_CS

to this: 对此:

class Ex15_CreateMeetingOnBehalfOfPrinciple_CS : System.Web.UI.Page

It looks like the problems you're getting are from properties you should be inheriting from that class. 看起来你遇到的问题来自你应该从该类继承的属性。

如果你的意思是HttpWebRequest,你应该使用System.Net包含命名空间;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM