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" %>