Reputation: 2308
I have an MVC Umbraco project and I'm trying to setup a simple search form. The search form uses basic HTML:
<form methed="GET">
<input name="s"... />
...
In the ascx.cs file that processes the search results, I have a Page_Load method that does the following:
protected void Page_Load(object sender, EventArgs e)
{
SearchTerm = Request.QueryString["s"];
...
The problem is that Request.Query
is always empty, even though the resulting URL clearly has the s
parameter in it.
Any thoughts as to why that would be invisible to this code behind file?
Also, to further confuse the situation, Request.RawUrl
returns the url with the query string in it.
Upvotes: 0
Views: 799
Reputation: 11
This happened to me using umbraco but turned out not to be an umbraco issue. RawUrl contained the query string but QueryString didn't.
The problem was that I was passing a url in the query string and had forgotten to encode it. This actually didn't matter when the url being passed in the query string didn't have its own query string, but when it did I guess c# saw the query string as malformed and so was unable to populate QueryString.
Upvotes: 1