Input english word, It works fine, chinese word, it goes wrong

If I input english word, It works fine. When I input chinese word, it goes wrong

In the error page, I Clicked the json format, it shows:

{"ResponseStatus":{"ErrorCode":"HttpRequestValidationException","Message":"从客户端(Name=\"&#22909;\")中检测到有潜在危险的 Request.QueryString 值。","StackTrace":"   在 System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection)\r\n   在 System.Web.HttpRequest.<>c__DisplayClass280_0.<ValidateHttpValueCollection>b__0(String key, String value)\r\n   在 System.Web.HttpValueCollection.EnsureKeyValidated(String key)\r\n   在 System.Web.HttpValueCollection.Get(String name)\r\n   在 ServiceStack.NameValueCollectionWrapper.get_Item(String name)\r\n   在 ServiceStack.HttpRequestExtensions.GetFlattenedRequestParams(IRequest request)\r\n   在 ServiceStack.Host.RestHandler.CreateRequest(IRequest httpReq, IRestPath restPath)\r\n   在 ServiceStack.Host.RestHandler.ProcessRequestAsync(IRequest httpReq, IResponse httpRes, String operationName)"}}

This StackTrace shows that the Exception is occurring inside ASP.NET’s HttpRequest.ValidateString, i.e:

System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection)\r\n

This validation is built into ASP.NET, you can potentially disable QueryString validation in your Web.config by adding:

<httpRuntime requestValidationMode="2.0" />

It Works, thanks! But It will generate

If I use HttpUtility.HtmlDecode(request.Name) , It shows fine.

Is there any setting or config don’t use ‘HttpUtility.HtmlDecode’ and can get the right result?

No we don’t typically use HtmlDecode when displaying text, but what page is this? Is this a page built into ServiceStack?

My project is used ServiceStackVS , choose the project templates “ServiceStack ASP.NET with Razor” , the default project include the hello.cshtml , input the Chinese words It Show Like the Image, you can try input 你好(hello)

If Click in other formats :json, xml , It Displays Right.

Then you’re just referring to /Views/Hello.cshtml which is just the default view that’s apart of the template:

@inherits ViewPage<AspNetRazor.ServiceModel.HelloResponse>

<h2 style="color:green">@Model.Result</h2>

<p><a href="/">&lt; home</a></p>

You can customize this as you wish.

I have found the reason, I added the
‘’ in the _Layout.cshtml , then all works fine.
and removed also works fine.