这个问题是关于安全威胁的。我想知道下面的用法可以在客户端更改 DropDownList 选择的值并影响服务器端吗?
这里的用法(aspx定义)
<asp:DropDownList AutoPostBack="true" ID="dropDownListDrawingArtists" CssClass="DropDownArtists"
runat="server">
</asp:DropDownList>
服务器端填充
if (IsPostBack == false)
{
if (srLang == "tr")
{
dropDownListDrawingArtists.Items.Add("Çizen Artist Filtresi: Bütün Çizen Artistler");
}
else
{
dropDownListDrawingArtists.Items.Add("Drawing Artist Filter: All Drawing Artists");
}
DataSet dsDrawingArtists = DbConnection.db_Select_Query("select DrawingArtist,COUNT(PokemonId) as Pokecount from tblPokedex group by DrawingArtist order by Pokecount desc,DrawingArtist asc");
for (int i = 0; i < dsDrawingArtists.Tables[0].Rows.Count; i++)
{
dropDownListDrawingArtists.Items.Add(dsDrawingArtists.Tables[0].Rows[i]["DrawingArtist"].ToString());
}
if (Session["FilterByArtist"] != null)
{
dropDownListDrawingArtists.SelectedIndex = Convert.ToInt32(Session["FilterByArtist"].ToString());
}
}
以及回发时的最终用法
if (dropDownListDrawingArtists.SelectedIndex > 0)
{
srFilterByDrawingArtist = " and DrawingArtist='" + dropDownListDrawingArtists.SelectedItem.ToString() + "'";
Session["FilterByArtist"] = dropDownListDrawingArtists.SelectedIndex.ToString();
}
如您所见,我直接在 SQL 查询中使用它。我在谷歌浏览器上测试了自己。更改了 dropDownListDrawingArtists 的值并进行了回发。服务器端的值没有受到影响。只是要确定
感谢您的回答
ASP.NET 4.0 C# 4.0