ASP.NET - 对URL传递的值进行编码Server.UrlEncode,

/// <summary>
/// 搜索内容
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSearch_Click(object sender, EventArgs e)
{
    string key = txtSearch.Text.Trim();

    string action = this.radTitle.Checked ? "byTitle" : "byContent";

    Response.Redirect("~/NewsSearch.aspx?key=" + Server.UrlEncode(key) + "&action=" + action + "");
}