2011-09-15 6 views
2

リクエストURLの例:http:\\localhost\ChatWindow.aspx?username=sly_chandanクエリー・ストリング・パラメーターを検索できません。

私のWebMethod属性を以下にリストされています。私は、クエリ文字列パラメータを取得するように見えることはできません

[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(); 
} 

+0

多分あなたが意味する||の代わりに && – onof

答えて

1

クエリ文字列を取得するには、単にこのように見えるようにあなたの方法を変更することができる必要があります:

[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(); 
} 
関連する問題