允许文本框中出现非法字符
我创建了一个文本框供用户输入评论。因此,有时他们会复制应用程序中出现的错误,并将其与注释一起粘贴到文本框中。它可能包含非法字符(例如 ),但应该保存它,但我的 .aspx 不允许。我不知道如何处理这个问题。谢谢!
I have created a textbox for my users to enter their comments. So, sometimes they copy the error that has been raised in the application and paste in the textbox along with comments. It may include illegal characters (eg. </11>
) but it should be saved but my .aspx is not allowing. I don't know how to handle this. thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您希望用户编辑文本框并输入 html 标签,您可以通过
或在整个应用程序的 web.config 中禁用此功能:
另一种智能解决方案是通过用户编写的 JavaScript 文本进行替换,以确保验证安全。
<代码>< anyword> ,而不是
被认为是安全的!If you want user to edit TextBox and enter html tags you can disable this via
or in the web.config for your entire application:
Another smart solution is to replace via javascript text written by user to make it safe for validation.
< anyword>
, instead of<anyword>
is considered safe!我假设您正在谈论一条异常消息,例如“从客户端检测到潜在危险的 Request.Form 值...”,
这是正在执行的 asp.net 请求验证。可以在页面或站点级别禁用此功能,但这样做存在风险。
这是通过页面指令或 web.config 中的 ValidateRequest="false" 完成的。
更多信息请参见:
http://www.asp.net/learn/whitepapers/request-validation
i assume you are talking about an exception message like "A potentially dangerous Request.Form value was detected from the client..."
that is the asp.net request validation in action. this can be disabled at the page or site level, but there are risks associated with doing so.
it is done with ValidateRequest="false" in the page directive or in web.config.
more information here:
http://www.asp.net/learn/whitepapers/request-validation
您可以尝试在传输之前对内容进行 Base64 编码。但我不确定我的解决方案是否真的很好。
http://nolovelust.com/post/classic-asp-base64-encoder -解码器.aspx
You can try to encode the content in Base64 before transferring it. But i'm not sure my solution is really good.
http://nolovelust.com/post/classic-asp-base64-encoder-decoder.aspx
这可能是由于出于安全预防措施 HTML 被服务器端拒绝。
您可以通过以下任一方式禁用此检查:
将以下属性添加到页面标题
<%@ Page validateRequest="false" %>
或在 Web.Config 中进行更改应用程序范围:
It could be due to the HTML being rejected server-side, as a security precaution.
You can disable this check by either:
Adding the following attribute to the page header
<%@ Page validateRequest="false" %>
or making the change application wide in the Web.Config: