I\'m trying to build a very, very simple \"micro-webapp\" which I suspect will be of interest to a few Stack Overflow\'rs if I ever get it done. I\'m hosting it on my C# in
You're definitely (IMHO) on the right track by not using runat="server" in your FORM tag. This just means you'll need to extract values from the Request.QueryString directly, though, as in this example:
In the .aspx page itself:
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="FormPage.aspx.cs" Inherits="FormPage" %>
ASP.NET with GET requests and no viewstate
Results:
Parameters
and in the code-behind:
using System;
public partial class FormPage : System.Web.UI.Page {
private string param1;
private string param2;
protected void Page_Load(object sender, EventArgs e) {
param1 = Request.QueryString["param1"];
param2 = Request.QueryString["param2"];
string result = GetResult(param1, param2);
ResultsPanel.Visible = (!String.IsNullOrEmpty(result));
Param1ValueLiteral.Text = Server.HtmlEncode(param1);
Param2ValueLiteral.Text = Server.HtmlEncode(param2);
ResultLiteral.Text = Server.HtmlEncode(result);
}
// Do something with parameters and return some result.
private string GetResult(string param1, string param2) {
if (String.IsNullOrEmpty(param1) && String.IsNullOrEmpty(param2)) return(String.Empty);
return (String.Format("You supplied {0} and {1}", param1, param2));
}
}
The trick here is that we're using ASP.NET Literals inside the value="" attributes of the text inputs, so the text-boxes themselves don't have to runat="server". The results are then wrapped inside an ASP:Panel, and the Visible property set on page load depending whether you want to display any results or not.