Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 asp.net 页面上有一个输入文本框,当用户输入任何标签(如中断标签或粗体)时,会发生错误。我目前正在使用以下内容对输入进行编码:
Server.HtmlEncode(mytextbox.Text)
然而,这只在字符没有被表述为 html 标签时才对字符进行编码,比如输入是否"<<<>>>>>"有办法让我允许用户放入标签而不会导致运行时错误?
"<<<>>>>>"
在您的ASP.NET页面的第一行中,只需禁用ValidateRequest:
ValidateRequest
<%@ Page Title="" Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" ValidateRequest="false" %>