Export (0) Print
Expand All

AntiXssEncoder.MarkAsSafe Method

.NET Framework 4.5

Marks characters from the specified Unicode code charts as safe.

Namespace:  System.Web.Security.AntiXss
Assembly:  System.Web (in System.Web.dll)

public static void MarkAsSafe(
	LowerCodeCharts lowerCodeCharts,
	LowerMidCodeCharts lowerMidCodeCharts,
	MidCodeCharts midCodeCharts,
	UpperMidCodeCharts upperMidCodeCharts,
	UpperCodeCharts upperCodeCharts
)

Parameters

lowerCodeCharts
Type: System.Web.Security.AntiXss.LowerCodeCharts

The combination of lower code charts to mark as safe.

lowerMidCodeCharts
Type: System.Web.Security.AntiXss.LowerMidCodeCharts

The combination of lower-middle code charts to mark as safe.

midCodeCharts
Type: System.Web.Security.AntiXss.MidCodeCharts

The combination of middle code charts to mark as safe.

upperMidCodeCharts
Type: System.Web.Security.AntiXss.UpperMidCodeCharts

The combination of upper-middle code charts to mark as safe.

upperCodeCharts
Type: System.Web.Security.AntiXss.UpperCodeCharts

The combination of upper code charts to mark as safe.

ExceptionCondition
InvalidOperationException

The AntiXssEncoder.MarkAsSafe(LowerCodeCharts, LowerMidCodeCharts, MidCodeCharts, UpperMidCodeCharts, UpperCodeCharts) method was called outside the Application_Start method in the Global.asax file.

The safe list affects all HTML XML, CSS, and URL encoding methods.

With some exceptions, Unicode code charts do not directly correspond to written languages. To add support for a specific language or set of languages often requires marking multiple code charts as safe.

To add support for the Japanese language while continuing to allow English, use the following syntax:

MarkAsSafe(
            LowerCodeCharts.Default,
            LowerMidCodeCharts.HangulJamo,
            MidCodeCharts.None,
            UpperMidCodeCharts.CjkRadicalsSupplement | 
            UpperMidCodeCharts.CjkSymbolsAndPunctuation | 
            UpperMidCodeCharts.Hiragana | 
            UpperMidCodeCharts.Katakana | 
            UpperMidCodeCharts.KatakanaPhoneticExtensions | 
            UpperMidCodeCharts.LatinExtendedD |
            UpperMidCodeCharts.CjkUnifiedIdeographs,
            UpperCodeCharts.None);
NoteNote

The MarkAsSafe method must be called in the Application_Start method in the Global.asax file.

.NET Framework

Supported in: 4.5

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft