I have the following method:
public object[] GetEventsByUser(DateTime start, DateTime end, string fullUrl)
The value of the fullUrl is:
http://localhost:50435/page/view.aspx?si=00&us=admin&ut=smt&
When I do:
NameValueCollection qscoll = HttpUtility.ParseQueryString(fullUrl);
I get:
{http%3a%2f%2flocalhost%3a50435%2fpage%2fview.aspx%3fsi=00&us=admin&ut=smt&}
But I need to obtain the parameters in the QueryString of this page, and with this value, I cannot obtain the "si" value, because the question mark, that starts the querystring is encoded. So I thought: "humm... I should try to do the HttpUtility.HtmlEncode()"
However the method HtmlEncode returns void: However the second parameter of this method sends the value to a TextWriter. But it i开发者_高级运维sn't the NameValueCollection.
Maybe the solution is simple... but I cannot see it.
You need to trim it down to just the querystring before parsing, like this:
if (fullUrl.Contains("?")) {
fullUrl = fullUrl.Substring(fullUrl.IndexOf("?") + 1);
}
NameValueCollection qscoll = HttpUtility.ParseQueryString(fullUrl);
You could try:
var si = Request["si"];
var user = Request["us"];
//etc.
精彩评论