I bring the data to the view via ViewData, sample code:

if (ViewData["post"] != null) { var post = ViewData["post"] as PostFull; string keywords = ""; post.passage = System.Text.RegularExpressions.Regex.Replace(post.passage, "<[^>]+>", string.Empty); <title>@post.title</title> <meta name="title" content="@post.title"> <meta name="description" content="@post.passage"> foreach (var tg in post.tags) { keywords += tg[1] + ","; } <meta name="keywords" content="@keywords"> } 

and at the exit I have:

 <title>&amp;#x41F;&amp;#x435;&amp;#x440;&amp;#x432;&amp;#x43E;&amp;#x43D;&amp;#x430;&amp;#x447;&amp;#x430;&amp;#x43B;&amp;#x44C;&amp;#x43D;&amp;#x430;&amp;#x44F; &amp;#x43D;&amp;#x430;&amp;#x441;&amp;#x442;&amp;#x440;&amp;#x43E;&amp;#x439;&amp;#x43A;&amp;#x430; Brocade ICX 6450, Ruckus ICX 7150</title> 

data in the PostFull class is collected from the database. Moreover, if you print @ html.raw, then everything is displayed normally, but for me it is somehow not correct. The browser itself in both cases displays as it should, but in the HTML source code these are the cracks.

How can I overcome this?

    2 answers 2

    You have in post.title , not the text "Первоначальная настройка" , but here is its coded representation: "&#x41F;&#x435;&#x440;&#x432;..." . You have somewhere once processed this text for output in HTML, a Razor @ does it again.

    Or make it so that in post.title a normal text, or indeed output it through raw .

     <div>&#x41F;&#x435;&#x440;&#x432;&#x43E;&#x43D;&#x430;&#x447;&#x430;&#x43B;&#x44C;&#x43D;&#x430;&#x44F; &#x43D;&#x430;&#x441;&#x442;&#x440;&#x43E;&#x439;&#x43A;&#x430; Brocade ICX 6450, Ruckus ICX 7150</div> 

    • for the experiment, I declare string ff = "hello" in the presentation itself; and immediately take it out @ff - and get the same krakozyabry - Zud71
    • I assume that to this Razor I should say somewhere in the settings that he should be friends with the Cyrillic alphabet, and not try to transform it - Zud71

    Here is the correct answer to my question. https://ru.stackoverflow.com/a/662453/332107

     public void ConfigureServices(IServiceCollection services) { .... //Чтобы кирилические символы не переводились в соответствующий Unicode Hex Character Code services.Configure<WebEncoderOptions>(options => { options.TextEncoderSettings = new TextEncoderSettings(UnicodeRanges.All); }); }