繁体   English   中英

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

[英]“The name 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);
                }
            }
        }

我是一个绝对的新手并且已经研究过这个错误但是对于我可能缺少哪个程序集作为参考感到困惑。

问题可能在这里

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

你的变量名是请求你正在使用请求

将此更改为

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

这将解决你的问题

改变这一行:

class Ex15_CreateMeetingOnBehalfOfPrinciple_CS

对此:

class Ex15_CreateMeetingOnBehalfOfPrinciple_CS : System.Web.UI.Page

看起来你遇到的问题来自你应该从该类继承的属性。

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

暂无
暂无

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

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