无法检索querystring参数. [英] Cannot retrieve a querystring parameter.
本文介绍了无法检索querystring参数.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请求URL的示例: http:\\ localhost \ ChatWindow.aspx?username = sly_chandan
我的网络方法如下:
[WebMethod(EnableSession = true)]
public static List<PrivateMessage> GetMessages()
{
List<PrivateMessage> getMsgsList = (List<PrivateMessage>)HttpContext.Current.Application["PrivateMessages"];
var msgs = getMsgsList.Where(x => x.fromUsername == HttpContext.Current.Session["Username"].ToString() && x.toUsername == HttpContext.Current.Request.QueryString["username"]);
return msgs.ToList();
}
我似乎无法检索querystring参数.
I cannot seem to retrieve the querystring parameter.
推荐答案
要获取查询字符串,您应该只需将您的方法更改为如下所示即可:
To get the querystring, you should simply be able to change your method to look like this:
[WebMethod(EnableSession = true)]
public static List<PrivateMessage> GetMessages(string username)
{
List<PrivateMessage> getMsgsList = (List<PrivateMessage>)HttpContext.Current.Application["PrivateMessages"];
var msgs = getMsgsList.Where(x => x.fromUsername == HttpContext.Current.Session["Username"].ToString() && x.toUsername == username;
return msgs.ToList();
}
这篇关于无法检索querystring参数.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文