C# 非发票会员';System.Web.HttpRequest.ServerVariables';不能像方法一样使用
我想检索如下值:C# 非发票会员';System.Web.HttpRequest.ServerVariables';不能像方法一样使用,c#,asp.net,.net,C#,Asp.net,.net,我想检索如下值: string server = Request.ServerVariables("SERVER_NAME"); //Declare the form being accessed ex: Default.aspx string url = Request.ServerVariables("URL"); // Declare the query string in the URL string querystring = Request.S
string server = Request.ServerVariables("SERVER_NAME");
//Declare the form being accessed ex: Default.aspx
string url = Request.ServerVariables("URL");
// Declare the query string in the URL
string querystring = Request.ServerVariables("QUERY_STRING");
但我有一个错误:
无法像方法一样使用非invocable成员“System.Web.HttpRequest.ServerVariables”
请帮我找出我的错误。谢谢。这是散列而不是方法。将()替换为[]您正试图以类似VB.Net的方式获取它。您必须使用
[]而不是()
。在C中使用#[]
,而在VB.Net中使用()
。e、 g
string server = Request.ServerVariables["SERVER_NAME"];
string url = Request.ServerVariables["URL"];
querystring = Request.ServerVariables["QUERY_STRING"];
Muhaammad@谢谢,我得到了一个solun。@Shree如果这有帮助的话,请不要忘记接受答案you@Jason我在stackoverflow是新手。我不知道如何接受它。请引导我。@Shree;请检查这个链接方括号是什么我错过了。。。从VB.Net转换虽然需要以这种方式提取服务器名称,ASP.Net将自动为您解析查询字符串和URL。因此,与其编写自己的解析代码,不如依赖框架,使用
Request.QueryString
和Request.Url
。(见附件)