如何从查询字符串中删除默认参数?

时间:2014-11-06 07:37:18

标签: asp.net webforms get query-string

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
  <form id="form1" action="WebForm1.aspx" method="get" runat="server">
  <div>
      <asp:TextBox ID="box" Text="information" runat="server"></asp:TextBox>
      <asp:Button ID="button" Text="Send" runat="server" />
  </div>
  </form>
</body>
</html>

我想用GET方法提交表单,但是asp.net在查询字符串中添加了一些带有长值的键。有时会导致HTTP错误414(Url太长)。我不想增加最大查询字符串长度,因为我读到这不是一个好习惯。是否可以从查询字符串中删除所有默认密钥?

当前查询字符串:

  

http://nothing.nothing/WebForm1.aspx?__VIEWSTATE=6%2B8%2FXwupCK6uWIQqkrHhtE399djdPKKA0QaUFFlcxlzVbFM0uU5M5lbjdTlKhdceIUdLtf4W3S6GapD%2BdD4wTRTsTCQHm4bHT653bTwm5u8%3D&__VIEWSTATEGENERATOR=C687F31A&__EVENTVALIDATION=yKG0mlw%2Fy9KPDZomSEGsg7y53PBYj%2FVqWCvgldVXoefw0x9v8Cs5lCgxslhu79w%2BzWoVnFvuLn%2Bnt%2FqTxH24Mg8sF57N9kKsDgn8nUfK6DuTMdTYHFqdym8HW9Sr16uRrSTkQfECEY72j3%2BhktfyNA%3D%3D&box=information&button=Send

理想的查询字符串:

  

http://nothing.nothing/WebForm1.aspx?box=information&button=Send

编辑:

我试图禁用ViewState,但没有任何改变。

protected void Page_Init(object sender, EventArgs e)
{
  EnableViewState = false;
}

我做错了吗?

0 个答案:

没有答案