打开重定向Fortify问题

时间:2013-06-27 12:39:41

标签: c#

最近,我开始研究fortify工具记录的一些安全问题。 我正在处理 Open Redirect 问题,我发现我们需要对Querystring参数值进行编码,所以我在我的示例应用程序中尝试了相同的approch但是当我观察时,输入数据没有被编码。

我尝试过类似下面的内容:

protected void Button1_Click(object sender, EventArgs e)
    {
        string s1 = TextBox1.Text;
        string s11 = HttpUtility.HtmlEncode(s1);
        Server.UrlEncode(s1);
        Server.HtmlEncode(s1);
        Response.Redirect(Server.UrlPathEncode("WebForm2.aspx?&Name=" + s11));
   }

当我在调试时看到它没有编码的值时,请帮助我在这里缺少什么。还有其他方法我可以解决它。

1 个答案:

答案 0 :(得分:0)

希望这是你在寻找

 protected void Button1_Click(object sender, EventArgs e)
 {
     string s1 = TextBox1.Text;
     string s11 = HttpUtility.UrlEncode(s1);
     Response.Redirect("WebForm2.aspx?&Name=" + s11));
 }