Penanya
Saya ingin melakukan pemindaian sqLinjection di dalam TextBoxes. Kode javascript yang saya tulis di texbox6-7 pada tampilan kedua tidak bekerja

Pertanyaan
-
Asp.net sayfam
<body onload="find();" > <form id="form1" runat="server"> <div> <table class="auto-style1"> <tr> <td class="auto-style2">Name Surname:</td> <td> <asp:TextBox ID="TextBox1" runat="server" Width="300px"></asp:TextBox> </td> </tr> <tr> <td class="auto-style2">Tel:</td> <td> <asp:TextBox ID="TextBox2" runat="server" Width="300px" Height="22px"></asp:TextBox> </td> </tr> <tr> <td class="auto-style2">Ağe:</td> <td> <asp:TextBox ID="TextBox3" runat="server" Width="300px"></asp:TextBox> </td> </tr> <tr> <td class="auto-style2">Class:</td> <td> <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" Width="300px"> <asp:ListItem Value="0">Select Class</asp:ListItem> <asp:ListItem>A1</asp:ListItem> <asp:ListItem>B1</asp:ListItem> </asp:DropDownList> </td> </tr> <tr> <td colspan="2"> <asp:MultiView ID="MultiView1" runat="server"> <asp:View ID="View1" runat="server"> <table class="auto-style1"> <tr> <td class="auto-style5" colspan="2">A Classes</td> </tr> <tr> <td class="auto-style8">Lesson Name : </td> <td> <asp:TextBox ID="TextBox4" runat="server" Width="300px"></asp:TextBox> </td> </tr> <tr> <td class="auto-style8">Lesson Teacher :</td> <td> <asp:TextBox ID="TextBox5" runat="server" Width="300px"></asp:TextBox> </td> </tr> </table> </asp:View> <asp:View ID="View2" runat="server"> <table class="auto-style1"> <tr> <td class="auto-style4" colspan="2">B Classes</td> </tr> <tr> <td class="auto-style7">Lesson Name : </td> <td> <asp:TextBox ID="TextBox6" runat="server" Width="300px"></asp:TextBox> </td> </tr> <tr> <td class="auto-style7">Lesson Teacher :</td> <td> <asp:TextBox ID="TextBox7" runat="server" Width="300px"></asp:TextBox> </td> </tr> </table> </asp:View> </asp:MultiView> </td> </tr> </table> </div> </form> </body>
Javascript code
var word = ["<", ">", "=", "where", "select", "from", "delete", "drop", "alter table", "table", "insert into", "update", "set", "join", "script", "body", "alert", "insert", "<script>"]; var txtBoxes = ['TextBox1', 'TextBox2', 'TextBox3', 'TextBox4', 'TextBox5', 'TextBox6', 'TextBox7']; var txtBox = new Array(); var find = function () { for (var i = 0; i <= txtBoxes.length; i++) { txtBox[i] = document.querySelector("#" + txtBoxes[i]); txtBox[i].addEventListener("keyup", control, true); txtBox[i].addEventListener("keydown", control, true); } } function control() { for (var i = 0; i < txtBox.length; i++) { for (var x = 0; x < word.length; x++) { txtBox[i].value = txtBox[i].value.replace(word[x], ""); } } }
Kode javascript juga tidak bekerja di kotak teks 6 dan 7. Saya ingin bantuan anda
Semua Balasan
-
hi,
Untuk masalah Anda, artinya bagaimana menghindari JavaScript Injection Attack.
Disini ada dua cara disarankan untuk Anda coba berikutinya:
Cara1: HTML Encode pada view
Cara yang mudah untuk menghindari JavaScript Injection attack adalah HTML encode data dimasuk oleh pengguna website kapan Anda redisplay data pada view.
Cara 2: HTML Encode pada controller.
Daripada HTML encoding data kapan Anda display data pada view, Anda bisa HTML encode data sebelum Anda mengajukan data ke database.
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com
Harap diingat untuk menandai balasan sebagai jawaban jika mereka membantu.
Jika Anda memiliki umpan balik untuk TechNet Subscriber Support, hubungi tnmff@microsoft.com- Disarankan sebagai Jawaban oleh Wendy DZMicrosoft contingent staff Senin, 12 Februari 2018 07.49
-
hi,
Sekarang apakah masalah ini udah diselesaikan atau ada update?
Terima Kasih
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com
Harap diingat untuk menandai balasan sebagai jawaban jika mereka membantu.
Jika Anda memiliki umpan balik untuk TechNet Subscriber Support, hubungi tnmff@microsoft.com