Asp.net SQL anti-injection code
Asp.net SQL anti-injection code
<% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "TestSQLInjection. aspx. cs" Inherits = "SQLInjection_TestSQLInjection" %>
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> No title page </title>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Div>
<Asp: TextBox ID = "TextBox1" runat = "server"> </asp: TextBox>
<Br/>
<Asp: TextBox ID = "TextBox2" runat = "server"> </asp: TextBox>
<Br/>
<Asp: TextBox ID = "TextBox3" runat = "server"> </asp: TextBox>
</Div>
<Asp: Button ID = "btnPost" runat = "server" onclick = "btnPost_Click"
Text = "get Post data"/>
<Asp: Button ID = "btnGet" runat = "server" onclick = "Button2_Click" Text = "Get data"/>
</Form>
</Body>
</Html>
Testsqlinjection. aspx. cs File
Using System;
Using System. Collections;
Using System. Configuration;
Using System. Data;
Using System. Linq;
Using System. Web;
Using System. Web. Security;
Using System. Web. UI;
Using System. Web. UI. HtmlControls;
Using System. Web. UI. WebControls;
Using System. Web. UI. WebControls. WebParts;
Using System. Xml. Linq;
Public partial class SQLInjection_TestSQLInjection: System. Web. UI. Page
{
Protected void Page_Load (object sender, EventArgs e)
{
}
Protected void Button2_Click (object sender, EventArgs e)
{
Response. Redirect ("TestSQLInjection. aspx? Id = 100 & cc = 200 & dd = 300 ");
}
Protected void btnPost_Click (object sender, EventArgs e)
{
}
}