我有一个搜索页面,我想阻止用户输入'到文本框,或用合适的字符替换它.任何人都可以帮助我在asp.net vb中实现这一目标吗?
例如,如果用户搜索O'Reilly,则搜索会因错误而崩溃:
Line 1: Incorrect syntax near 'Reilly'. Unclosed quotation mark before the character string ' '.
Run Code Online (Sandbox Code Playgroud)
谢谢!
请告诉我InputFile.PostedFile.ContentLength测量的单位.我需要确保文件小于500k.
谢谢.
我有一个arraylist:
Dim downloadsarray As New ArrayList
downloadsarray.Add(iconlink)
downloadsarray.Add(imgpath)
downloadsarray.Add(filesize)
downloadsarray.Add(description)
Run Code Online (Sandbox Code Playgroud)
哪个是我的中继器的数据源:
DownloadsRepeater.DataSource = downloadsarray
DownloadsRepeater.DataBind()
Run Code Online (Sandbox Code Playgroud)
请问您能告诉我如何将数组中的项输出到.aspx页面.我经常使用(当使用sqldatareader作为数据源时):
<%#Container.DataItem("1stcolumnnamestring")%>
<%#Container.DataItem("2ndcolumnnamestring")%>
Run Code Online (Sandbox Code Playgroud)
但是当使用arraylist作为数据源时,这不起作用.
谢谢.
ps ...我知道如何使用<%#Container.DataItem%>来转储所有内容,但我需要单独获取数组中的项目,而不是一次性将它们全部丢弃到页面中.例如,项目1包含链接,项目2包含图像路径,项目3包含描述.我需要以正确的顺序踢出它们才能正确构建链接和图标.
我想像这样更新一行:
update [approvers] set approvalstatus = True Where approvalstatus = False and bookingID = @bookingid and approveremail = @email
Run Code Online (Sandbox Code Playgroud)
使用实体框架.
我的查询应该像这样传递项目:
Dim db As New Model.Entities
Dim approvers = From a In db.approvers Where a.ApprovalStatus = False And a.BookingID = BookingID And a.ApproverEmail = UserName Select a.ApprovalStatus
Run Code Online (Sandbox Code Playgroud)
我如何下一步将此记录作为更新目标,以便我可以设置a.approvalStatus = True然后将这些更改提交给db?
谢谢.
在一些友好的堆栈溢出成员的帮助下,我重新编写了我的代码(特别感谢Martin B和Kev Chadders).我现在想检查一下这项工作后我的代码是否仍然对SQL注入开放.我相信代码现在可以正常工作,但是你看到的任何致盲错误我都会喜欢听到.我的代码现在看起来像:
-code removed-
Run Code Online (Sandbox Code Playgroud) 我一直在使用以下代码共享数据库变量:
Namespace DataAccessVariables
Public Class Vars
Public Shared s As String
Public Shared con As String = WebConfigurationManager.ConnectionStrings("Dev").ToString()
Public Shared c As New SqlConnection(con)
Public Shared x As New SqlCommand(s, c)
End Class
End Namespace
Run Code Online (Sandbox Code Playgroud)
然后我将其导入我的项目,如下所示:
Imports DataAccessVariables.Vars
Run Code Online (Sandbox Code Playgroud)
当我用FXCop检查网站时,我收到以下消息:
Error, Certainty 90, for StaticHolderTypesShouldNotHaveConstructors
{
Target : DBVars (IntrospectionTargetType)
Resolution : "Remove the public constructors from 'Vars'."
Help : http://msdn2.microsoft.com/library/ms182169(VS.90).aspx (String)
Category : Microsoft.Design (String)
CheckId : CA1053 (String)
RuleFile : Design Rules (String)
Info : "Instances of types that …Run Code Online (Sandbox Code Playgroud) 我将1,2,3,4,5,6,7,8,9存储为我的数据库中Level的nvarchar.
然后我有一个值为1,2,3,4,5,6,7,8,9的下拉列表.当用户进行选择时(即1)(Level.SelectedValue.ToString).这通过这样的param构建一个sql查询:
"Select things From MBA_EOI Where level = 1"
Run Code Online (Sandbox Code Playgroud)
当我运行选择时,我得到以下错误:
Syntax error converting the nvarchar value '1,2,3,4,5,6,7,8,9' to a column of data type int.
Run Code Online (Sandbox Code Playgroud)
我的印象是我正在处理Nvarchar字段并将所选值作为字符串,int转换在哪里进来?
ps我也试过Level.SelectedItem.ToString
我有许多参数构成插入表单,例如:
x.Parameters.AddWithValue("@city", City.Text)
Run Code Online (Sandbox Code Playgroud)
我今天早上在网站上发生了一次失败的xss攻击,所以无论如何我都试图加强安全措施....
我应该像这样添加我的输入参数吗?
x.Parameters.AddWithValue("@city", HttpUtility.HtmlEncode(City.Text))
Run Code Online (Sandbox Code Playgroud)
还有什么我应该考虑避免攻击吗?
asp.net ×7
vb.net ×5
ado.net ×1
arraylist ×1
code-sharing ×1
database ×1
datasource ×1
declaration ×1
file-upload ×1
filesize ×1
fxcop ×1
html-encode ×1
parameters ×1
repeater ×1
security ×1
sql ×1
string ×1
validation ×1
xss ×1