I have a problem with Request.QueryString that returns a null value. I think that is from OutputCache
I have in Default.aspx (with master file)
<%@ OutputCache Duration="60" VaryByParam="button" %>
<script runat="server">
protected void Page_Load( object sender, EventArgs e ) {
TimeMsg.Text = DateTime.Now.ToString( "G" );
string v = Request.QueryString["button"];
PageName.Text = v;
}
</script>
<form method="get" action="Default.aspx">
<h5>Click a button</h5>
<input type="submit" name="button" value="One" />
<input type="submit" name="button" value="Two" />
<input type="submit" name="button" value="Three" />
</form>
<p>Page generated at : <asp:Label ID="TimeMsg" runat="server"></asp:Label></p>
<p>Page name : <asp:Label ID="PageName" runat="server"></asp:Label></p>
I don’t write anymore the <asp:Content ID='' ...></asp> tag.
When I press one of button, the PageName returns empty that I checked the v variable with Debugger and I see that it returns null.
Why ?
If you change
Request.QueryString["button"];toRequest.Form["button"];you will get the expected output. This is probably because ofFormin your master page.