gpt4 book ai didi

c# - "The name does not exist in the current context"

转载 作者:太空狗 更新时间:2023-10-30 01:36:15 24 4
gpt4 key购买 nike

我收到以下错误;当前上下文中不存在名称“请求”

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;

你的变量名是request bt你正在使用Request

改成

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

这会解决你的问题

关于c# - "The name does not exist in the current context",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22801182/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com