{"id":176095,"date":"2013-04-09T22:54:06","date_gmt":"2013-04-09T18:54:06","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=176095"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=176095","title":{"rendered":"<span class=\"post_title\">ASP.NET MVC \u0423\u0440\u043e\u043a C. \u041c\u043d\u043e\u0433\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u0439 \u0441\u0430\u0439\u0442<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t<b>\u0426\u0435\u043b\u044c \u0443\u0440\u043e\u043a\u0430.<\/b> \u041d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u0435 \u0441\u0430\u0439\u0442\u044b. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0411\u0414. \u0420\u0435\u0441\u0443\u0440\u0441\u044b \u0441\u0430\u0439\u0442\u0430. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u044f\u0437\u044b\u043a\u0430. \u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u044f\u0437\u044b\u043a\u0430\u043c\u0438. \u0420\u0430\u0431\u043e\u0442\u0430 \u0432 \u0430\u0434\u043c\u0438\u043d\u043a\u0435.<\/p>\n<h5>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043c\u043d\u043e\u0433\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u0433\u043e \u0441\u0430\u0439\u0442\u0430<\/h5>\n<p>  \u0418\u0442\u0430\u043a, \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a \u043f\u0440\u043e\u0441\u0438\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0430\u0439\u0442 \u043c\u043d\u043e\u0433\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u043c, \u0442.\u0435. \u0447\u0442\u043e\u0431\u044b \u0438 \u043f\u043e-\u0440\u0443\u0441\u0441\u043a\u0438, \u0438 \u043f\u043e-\u0444\u0440\u0430\u043d\u0446\u0443\u0437\u043a\u0438, \u0438 \u043f\u043e-\u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043a\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u043d\u043e\u0433\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u0439 \u0431\u043b\u043e\u0433, \u0442\u0430\u043a \u0438 \u0433\u043e\u0441\u0442\u0438\u043d\u0438\u0447\u043d\u044b\u0439 \u0441\u0430\u0439\u0442, \u0441\u0430\u0439\u0442 \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043d\u0435\u0434\u0432\u0438\u0436\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435. <br \/>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c, \u0447\u0442\u043e \u0436\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c:  <\/p>\n<ul>\n<li>\u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0434\u0430\u0442, \u0441\u0443\u043c\u043c \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0421 \u044d\u0442\u0438\u043c \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441 System.Globalization<\/li>\n<li>\u0412\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0441\u0430\u0439\u0442\u0430 \u2014 \u0432\u044b\u0434\u0430\u0447\u0430 \u043e\u0448\u0438\u0431\u043a\u0438 (\u00ab\u041f\u043e\u043b\u0435 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0443\u0441\u0442\u044b\u043c\u00bb, \u00abThe field is required\u00bb) \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f.<\/li>\n<li>\u041d\u0435 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b, \u043a\u0430\u043a \u0442\u043e \u043b\u043e\u0433\u043e\u0442\u0438\u043f\u044b, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, js-\u043b\u043e\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u043d\u0430\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044f\u0437\u044b\u043a\u0430 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435.<\/li>\n<li>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. <\/li>\n<\/ul>\n<p>  <a name=\"habracut\"><\/a><br \/>   \u0415\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438\u0445.  <\/p>\n<ul>\n<li>\u0421\u0430\u043c\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u2014 \u044d\u0442\u043e \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u0430\u0439\u0442\u044b. \u041d\u0443\u0436\u0435\u043d \u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u0441\u0430\u0439\u0442 \u2014 \u0441\u0434\u0435\u043b\u0430\u043b\u0438. \u041d\u0443\u0436\u0435\u043d \u043f\u0435\u0440\u0435\u0432\u043e\u0434, \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0441\u0430\u0439\u0442, \u043f\u0435\u0440\u0435\u0432\u0435\u043b\u0438 \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0432\u0441\u0451. \u042d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c, \u043a\u043e\u0433\u0434\u0430 \u0441\u0430\u0439\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439, \u0432\u0441\u0435\u0433\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0439 \u0438 \u043d\u0435\u0442 \u0430\u0434\u043c\u0438\u043d\u043a\u0438. <\/li>\n<li>\u0420\u0430\u0437\u043d\u044b\u0435 \u0411\u0414. \u0421\u0430\u0439\u0442 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043a \u043e\u0434\u043d\u043e\u0439 \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u0411\u0414. \u0415\u0441\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u044f\u0437\u044b\u043a \u2013 \u0442\u043e \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u0441\u044f \u0411\u0414 \u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0441\u0430\u0439\u0442\u0430. \u041d\u043e \u0411\u0414 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435, \u0438 \u0441\u0442\u0430\u0442\u044c\u044f, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u0430\u044f \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u044f\u0437\u044b\u043a\u0435, \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439, \u043f\u043b\u044e\u0441 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c.<\/li>\n<li>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445. <\/li>\n<\/ul>\n<p>  \u0421\u0440\u0430\u0437\u0443 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0440\u0435\u0442\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c, \u043a\u0430\u043a \u043c\u044b \u044d\u0442\u043e \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0443\u0435\u043c \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438:  <\/p>\n<ul>\n<li>\u0412 \u0430\u0434\u0440\u0435\u0441\u0435 \u0441\u0430\u0439\u0442\u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 lang <br \/> \n<ul>\n<li>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0430\u0434\u0440\u0435\u0441 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0432\u0438\u0434 <code>http:\/\/our-site.com\/{lang}\/{controller}\/{action}<\/code> <\/li>\n<li>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0430\u0434\u0440\u0435\u0441 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0432\u0438\u0434 <code>http:\/\/our-site.com\/{controller}\/{action}?lang=ru<\/code><\/li>\n<\/ul>\n<p>  <\/li>\n<li>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 lang \u2013 \u044d\u0442\u043e ISO \u0434\u0432\u0443\u0445\u0431\u0443\u043a\u0432\u0435\u043d\u043d\u043e\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u044f\u0437\u044b\u043a\u0430 (ru \u2013 \u0440\u0443\u0441\u0441\u043a\u0438\u0439, uk \u2013 \u0443\u043a\u0440\u0430\u0438\u043d\u0441\u043a\u0438\u0439, cs \u2013 \u0447\u0435\u0448\u0441\u043a\u0438\u0439)<\/li>\n<li>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c System.Globalization \u0434\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430 \u0434\u0430\u0442 <\/li>\n<li>\u041e\u0440\u0433\u0430\u043d\u0438\u0437\u0443\u0435\u043c \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u043e\u0448\u0438\u0431\u043a\u0438 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u043e\u0432<\/li>\n<li>\u041e\u0440\u0433\u0430\u043d\u0438\u0437\u0443\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u0411\u0414 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043f\u043e\u043b\u0435\u0439.<\/li>\n<\/ul>\n<p>  \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c 2 \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u2013 \u0440\u0443\u0441\u0441\u043a\u0443\u044e \u0438 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0443\u044e, \u043f\u0440\u0438\u0447\u0435\u043c \u0440\u0443\u0441\u0441\u043a\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<br \/>  \u2003  <\/p>\n<h5>Routing <\/h5>\n<p>  \u0412 DefaultAreaRegistration \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 lang (\/Areas\/Default\/DefaultAreaRegistration.cs):  <\/p>\n<pre><code class=\"cs\">context.MapRoute(                 name: &quot;lang&quot;,                 url: &quot;{lang}\/{controller}\/{action}\/{id}&quot;,                 defaults: new { controller = &quot;Home&quot;, action = &quot;Index&quot;, id = UrlParameter.Optional },                 constraints : new { lang = @&quot;ru|en&quot; },                 namespaces: new[] { &quot;LessonProject.Areas.Default.Controllers&quot; }             );              context.MapRoute(                 name : &quot;default&quot;,                 url : &quot;{controller}\/{action}\/{id}&quot;,                 defaults : new { controller = &quot;Home&quot;, action = &quot;Index&quot;, id = UrlParameter.Optional, lang = &quot;ru&quot; },                 namespaces : new [] { &quot;LessonProject.Areas.Default.Controllers&quot; }             ); <\/code><\/pre>\n<p>  \u0418\u0442\u0430\u043a, \u0435\u0441\u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0430 \u0443 \u043d\u0430\u0441 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 lang, \u0442\u043e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u201clang\u201d. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 contstrains (\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f), \u0442\u0443\u0442 \u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u044f\u0437\u044b\u043a \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e ru \u0438\u043b\u0438 en. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f, \u0442\u043e \u043c\u044b \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u2013 \u201cdefault\u201d, \u0433\u0434\u0435 \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e lang=ru.<br \/>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u044d\u0442\u043e \u0434\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 DefaultController \u0434\u043b\u044f \u0441\u043c\u0435\u043d\u044b \u043a\u0443\u043b\u044c\u0442\u0443\u0440\u044b \u043f\u043e\u0442\u043e\u043a\u0430 (Thread.Current.CurrentCulture) (\/Areas\/Default\/DefaultController.cs):  <\/p>\n<pre><code class=\"cs\">public class DefaultController : BaseController     {         public string CurrentLangCode { get; protected set; }          public Language CurrentLang { get; protected set; }          protected override void Initialize(System.Web.Routing.RequestContext requestContext)         {             if (requestContext.HttpContext.Request.Url != null)             {                 HostName = requestContext.HttpContext.Request.Url.Authority;             }              if (requestContext.RouteData.Values[&quot;lang&quot;] != null && requestContext.RouteData.Values[&quot;lang&quot;] as string != &quot;null&quot;)             {                 CurrentLangCode = requestContext.RouteData.Values[&quot;lang&quot;] as string;                 CurrentLang = Repository.Languages.FirstOrDefault(p =&gt; p.Code == CurrentLangCode);                  var ci = new CultureInfo(CurrentLangCode);                 Thread.CurrentThread.CurrentUICulture = ci;                 Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(ci.Name);             }             base.Initialize(requestContext);         }     }  <\/code><\/pre>\n<p>  \u2003<br \/>  \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432 BaseController \u043c\u044b \u0443\u0431\u0438\u0440\u0430\u0435\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043a\u0443\u043b\u044c\u0442\u0443\u0440\u044b \u043f\u043e\u0442\u043e\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b (\/Controllers\/BaseController.cs):  <\/p>\n<pre><code class=\"cs\">protected override void Initialize(System.Web.Routing.RequestContext requestContext)         {             if (requestContext.HttpContext.Request.Url != null)             {                 HostName = requestContext.HttpContext.Request.Url.Authority;             }             base.Initialize(requestContext);         } <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c, \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u043a\u0430\u043a \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u044b\u0432\u043e\u0434 \u0434\u0430\u0442\u044b:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/4da\/081\/a77\/4da081a77f1a864872800821e76b3da9.jpg\"\/><\/p>\n<p>  \u041f\u0435\u0440\u0432\u044b\u0439 \u044d\u0442\u0430\u043f \u043f\u0440\u043e\u0439\u0434\u0435\u043d. \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c \u0441\u0430\u0439\u0442\u0430.<\/p>\n<h5>\u0420\u0435\u0441\u0443\u0440\u0441\u044b \u0441\u0430\u0439\u0442\u0430<\/h5>\n<p>  \u0420\u0435\u0441\u0443\u0440\u0441\u044b \u0441\u0430\u0439\u0442\u0430 \u2013 \u044d\u0442\u043e \u0432\u0441\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0434\u043e \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438:  <\/p>\n<ul>\n<li>\u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0435\u043d\u044e<\/li>\n<li>\u041f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438<\/li>\n<li>\u0412\u044b\u0432\u043e\u0434\u044b \u043e\u0448\u0438\u0431\u043e\u043a<\/li>\n<\/ul>\n<p>  \u041d\u0430 \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0443 \u043d\u0430\u0441 \u0442\u0430\u043a\u0438\u0445 \u0441\u0442\u0440\u043e\u043a \u0447\u0435\u0442\u044b\u0440\u0435: \u0440\u043e\u043b\u0438, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438, \u0432\u0445\u043e\u0434 \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b:<\/p>\n<ul>\n<li>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0430\u043f\u043a\u0443 Asp.net \u043f\u0430\u043f\u043a\u0443 App_LocalResources:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/693\/9a0\/81e\/6939a081e09094e69e996ac763bc301d.jpg\"\/>  <\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u043d\u0435\u0439 \u0444\u0430\u0439\u043b\u044b GlobalRes.resx \u0438 GlobalRes.en.resx:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/582\/c7e\/7be\/582c7e7be135f12b4297ef74de2976fb.jpg\"\/>  <\/li>\n<li>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043d\u0438\u0445 \u043d\u0430\u0448\u0438 \u0441\u0442\u0440\u043e\u043a\u0438, \u0432 GlobalRes \u2013 \u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u043f\u0435\u0440\u0435\u0432\u043e\u0434, \u0432 GlobalRes.en \u2013 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u0439:<br \/>\n<table>\n<tr>\n<td>Enter<\/td>\n<td>\u0412\u0445\u043e\u0434<\/td>\n<\/tr>\n<tr>\n<td>Register<\/td>\n<td>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f<\/td>\n<\/tr>\n<tr>\n<td>Roles<\/td>\n<td>\u0420\u043e\u043b\u0438<\/td>\n<\/tr>\n<tr>\n<td>Users<\/td>\n<td>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438<\/td>\n<\/tr>\n<\/table>\n<\/li>\n<li>\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0434\u043b\u044f GlobalRes \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0435\u0439<br \/> \n<ul>\n<li>Build Action: Embedded Resource<\/li>\n<li>Custom Tool: PublicResXFileCodeGenerator<\/li>\n<\/ul>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/694\/f44\/ce9\/694f44ce919c62cba140d13caea72c56.jpg\"\/>  <\/li>\n<li>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c namespace LessonProject.App_LocalResources \u0432 Web.cofig \u0432 system.web.webPages.razor (Web.config):<br \/> \n<pre><code class=\"xml\">&lt;system.web.webPages.razor&gt;     &lt;pages pageBaseType=&quot;System.Web.Mvc.WebViewPage&quot;&gt;       &lt;namespaces&gt;         &lt;add namespace=&quot;LessonProject.Helper&quot; \/&gt;         &lt;add namespace=&quot;LessonProject.Tools&quot; \/&gt;         &lt;add namespace=&quot;LessonProject.App_LocalResources&quot; \/&gt;       &lt;\/namespaces&gt;     &lt;\/pages&gt;   &lt;\/system.web.webPages.razor&gt; <\/code><\/pre>\n<p>  <\/li>\n<li>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432 UserLogin.cshtml (\/Areas\/Default\/Views\/Home\/UserLogin.cshtml) \u0438 Index.cshtml ((\/Areas\/Default\/Views\/Home\/Index.cshtml):<br \/> \n<pre><code class=\"html\">@model LessonProject.Model.User  @if (Model != null) {     &lt;li&gt;@Model.Email&lt;\/li&gt;     &lt;li&gt;@Html.ActionLink(&quot;\u0412\u044b\u0445\u043e\u0434&quot;, &quot;Logout&quot;, &quot;Login&quot;)&lt;\/li&gt; } else {     &lt;li&gt;&lt;span class=&quot;btn btn-link&quot; id=&quot;LoginPopup&quot;&gt;@GlobalRes.Enter&lt;\/span&gt;&lt;\/li&gt;     &lt;li&gt;@Html.ActionLink(GlobalRes.Register, &quot;Register&quot;, &quot;User&quot;)&lt;\/li&gt; }  \u2026  @{     ViewBag.Title = &quot;LessonProject&quot;;     Layout = &quot;~\/Areas\/Default\/Views\/Shared\/_Layout.cshtml&quot;; } &lt;h2&gt;LessonProject &lt;\/h2&gt; &lt;p&gt;     @DateTime.Now.ToString(&quot;D&quot;)     &lt;div class=&quot;menu&quot;&gt;     &lt;a href=&quot;@Url.Action(&quot;Index&quot;, &quot;Role&quot;, new { id = &quot;1&quot; })&quot;&gt;@GlobalRes.Roles&lt;\/a&gt;     @Html.ActionLink(GlobalRes.Users,  &quot;Index&quot;, &quot;User&quot;)     &lt;\/div&gt;      &lt;\/p&gt; <\/code><\/pre>\n<p>  <\/li>\n<\/ul>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/fe3\/693\/694\/fe3693694bea59bdbea831f159fd4c43.jpg\"\/><\/p>\n<p>  \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0437\u0430\u0434\u0430\u043d\u0438\u044e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 LoginView:  <\/p>\n<ul>\n<li>\u0412\u044b\u0434\u0435\u043b\u044f\u0435\u043c ErrorMessage \u0434\u043b\u044f \u043f\u043e\u043b\u0435\u0439 \u0432 \u0440\u0435\u0441\u0443\u0440\u0441\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b (\/App_LocalResources\/GlobalRes.resx):<br \/> <br \/>\n<table>\n<tr>\n<td>EnterEmail<\/td>\n<td>\u0412\u0432\u0435\u0434\u0438\u0442\u0435 email<\/td>\n<\/tr>\n<tr>\n<td>EnterPassword<\/td>\n<td>\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043f\u0430\u0440\u043e\u043b\u044c<\/td>\n<\/tr>\n<\/table>\n<p>  <\/li>\n<li>\u0417\u0430\u0434\u0430\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0432 LoginView.cs (\/Models\/ViewModel\/LoginView.cs):<br \/> \n<pre><code class=\"cs\">public class LoginView     {         [Required(ErrorMessageResourceType=typeof(GlobalRes), ErrorMessageResourceName=&quot;EnterEmail&quot;)]         public string Email { get; set; }          [Required(ErrorMessageResourceType = typeof(GlobalRes), ErrorMessageResourceName = &quot;EnterPassword&quot;)]         public string Password { get; set; }          public bool IsPersistent { get; set; }     } <\/code><\/pre>\n<p>  <\/li>\n<\/ul>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0432 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 <a href=\"http:\/\/localhost\/en\/Login\">localhost\/en\/Login<\/a>: <br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/025\/30f\/7bb\/02530f7bb4b5d2ed9088486c20a0eaf0.jpg\"\/><\/p>\n<p>  \u041d\u043e \u0434\u043b\u044f popup \u0432\u0445\u043e\u0434\u0430 \u044d\u0442\u0438 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f \u0442\u0430\u043a \u0438 \u043e\u0441\u0442\u0430\u043d\u0443\u0442\u0441\u044f \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435, \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043c\u044b \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 popup-\u0431\u043b\u043e\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c url \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0437\u0430\u0434\u0430\u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 lang, \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u044d\u0442\u043e:  <\/p>\n<ul>\n<li>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u0440\u0435\u0441\u0443\u0440\u0441\u044b (\/App_LocalResources\/GlobalRes(.en).resx)CurrentLang = ru \u0438 CurrentLang = en<\/li>\n<li>\u0412\u044b\u0432\u0435\u0434\u0435\u043c \u044d\u0442\u043e \u0432 hidden-\u043f\u043e\u043b\u0435 \u0432 _Layout.cshtml (\/Areas\/Default\/Views\/Shared\/_Layout.cshtml):<br \/> \n<pre><code class=\"javascript\">&lt;body&gt;     @Html.Hidden(&quot;CurrentLang&quot;, GlobalRes.CurrentLang)     &lt;div class=&quot;navbar navbar-fixed-top&quot;&gt; \u2022\t\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u044d\u0442\u043e \u0432 ajax-\u0432\u044b\u0437\u043e\u0432\u044b (\/Scripts\/common.js): _this = this;     this.loginAjax = &quot;\/Login\/Ajax&quot;;      this.init = function ()     {         _this.loginAjax = &quot;\/&quot; + $(&quot;#CurrentLang&quot;).val() + _this.loginAjax;         $(&quot;#LoginPopup&quot;).click(function () {             _this.showPopup(_this.loginAjax, initLoginPopup);         });     }    function initLoginPopup(modal) {         $(&quot;#LoginButton&quot;).click(function () {             $.ajax({                 type: &quot;POST&quot;,                 url: _this.loginAjax,                 data : $(&quot;#LoginForm&quot;).serialize(), <\/code><\/pre>\n<p>  <\/li>\n<\/ul>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/183\/634\/0e0\/1836340e0f3ff83d8a8f4203be5c57a2.jpg\"\/><\/p>\n<h5>\u0411\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 <\/h5>\n<p>  \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u0432\u0430\u0436\u043d\u043e\u043c\u0443 \u0440\u0430\u0437\u0434\u0435\u043b\u0443, \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0411\u0414. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u0442\u0438\u043f\u0430 Post (\u0431\u043b\u043e\u0433\u043e-\u0437\u0430\u043f\u0438\u0441\u044c), \u043a\u043e\u0442\u043e\u0440\u0430\u044f, \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043d\u0430 \u0434\u0432\u0443\u0445 \u044f\u0437\u044b\u043a\u0430\u0445:  <\/p>\n<table>\n<tr>\n<td>ID<\/td>\n<td>\u0423\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u0437\u0430\u043f\u0438\u0441\u0438 <\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>UserID <\/td>\n<td>\u0410\u0432\u0442\u043e\u0440 \u0437\u0430\u043f\u0438\u0441\u0438<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>Header <\/td>\n<td>\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a <\/td>\n<td>\u0422\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430<\/td>\n<\/tr>\n<tr>\n<td>Url <\/td>\n<td>Url \u0437\u0430\u043f\u0438\u0441\u0438<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>Content <\/td>\n<td>\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0437\u0430\u043f\u0438\u0441\u0438<\/td>\n<td>\u0422\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430<\/td>\n<\/tr>\n<tr>\n<td>AddedDate<\/td>\n<td>\u0414\u0430\u0442\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f<\/td>\n<td><\/td>\n<\/tr>\n<\/table>\n<p>  \u0418\u0442\u0430\u043a, \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u0441\u0451 \u0431\u0443\u0434\u0435\u0442 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043d\u043e:  <\/p>\n<ul>\n<li>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 Language, \u0433\u0434\u0435 \u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u044f\u0437\u044b\u043a\u0438 <\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 Post, \u0433\u0434\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u0441\u0435 \u043f\u043e\u043b\u044f, \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0438\u0435 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430<\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 PostLang, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0443\u044e \u0441 Post \u0438 Language, \u0433\u0434\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043f\u043e\u043b\u0435\u0439 \u0434\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b Post \u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439 Language<\/li>\n<\/ul>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/322\/de2\/f30\/322de2f308ac2162725472cf1a1c7254.jpg\"\/><\/p>\n<p>  \u041e\u043a, \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u044d\u0442\u043e \u0432 LessonProject.Model (LessonProject.Model\/IRepository.cs):  <\/p>\n<pre><code class=\"cs\">#region Language          IQueryable&lt;Language&gt; Languages { get; }          bool CreateLanguage(Language instance);          bool UpdateLanguage(Language instance);          bool RemoveLanguage(int idLanguage);          #endregion           #region Post          IQueryable&lt;Post&gt; Posts { get; }          bool CreatePost(Post instance);          bool UpdatePost(Post instance);          bool RemovePost(int idPost);          #endregion <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043d\u0438\u043f\u043f\u0435\u0442\u043e\u0432 \/Proxy\/Language.cs:  <\/p>\n<pre><code class=\"cs\"> namespace LessonProject.Model {     public partial class Language     {     } } <\/code><\/pre>\n<p>  \u2003<br \/>   \/Proxy\/Post.cs:  <\/p>\n<pre><code class=\"cs\">namespace LessonProject.Model {     public partial class Post     {     } } <\/code><\/pre>\n<p>  \/SqlRepository\/Language.cs:  <\/p>\n<pre><code class=\"cs\">public partial class SqlRepository     {         public IQueryable&lt;Language&gt; Languages         {             get             {                 return Db.Languages;             }         }          public bool CreateLanguage(Language instance)         {             if (instance.ID == 0)             {                 Db.Languages.InsertOnSubmit(instance);                 Db.Languages.Context.SubmitChanges();                 return true;             }              return false;         }          public bool UpdateLanguage(Language instance)         {             Language cache = Db.Languages.Where(p =&gt; p.ID == instance.ID).FirstOrDefault();             if (cache != null)             {                 cache.Code = instance.Code;                 cache.Name = instance.Name;                 Db.Languages.Context.SubmitChanges();                 return true;             }              return false;         }          public bool RemoveLanguage(int idLanguage)         {             Language instance = Db.Languages.Where(p =&gt; p.ID == idLanguage).FirstOrDefault();             if (instance != null)             {                 Db.Languages.DeleteOnSubmit(instance);                 Db.Languages.Context.SubmitChanges();                 return true;             }              return false;         }              } <\/code><\/pre>\n<p>  \/SqlRepository\/Post.cs:  <\/p>\n<pre><code class=\"cs\">public partial class SqlRepository     {         public IQueryable&lt;Post&gt; Posts         {             get             {                 return Db.Posts;             }         }          public bool CreatePost(Post instance)         {             if (instance.ID == 0)             {                 Db.Posts.InsertOnSubmit(instance);                 Db.Posts.Context.SubmitChanges();                 return true;             }              return false;         }          public bool UpdatePost(Post instance)         {             Post cache = Db.Posts.Where(p =&gt; p.ID == instance.ID).FirstOrDefault();             if (cache != null)             {                 \/\/TODO : Update fields for Post                 Db.Posts.Context.SubmitChanges();                 return true;             }              return false;         }          public bool RemovePost(int idPost)         {             Post instance = Db.Posts.Where(p =&gt; p.ID == idPost).FirstOrDefault();             if (instance != null)             {                 Db.Posts.DeleteOnSubmit(instance);                 Db.Posts.Context.SubmitChanges();                 return true;             }              return false;         }              } <\/code><\/pre>\n<p>  \u0418\u0442\u0430\u043a, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0430\u0431\u043e\u0440 PostLangs \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 Post, \u0433\u0434\u0435 \u0438 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u044b. \u041f\u0440\u0438\u0447\u0435\u043c, \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u0439 \u0438\u043b\u0438 \u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u044f\u0437\u044b\u043a \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c, \u0442\u0430\u043a \u043c\u043e\u0436\u0435\u0442 \u0438 \u043d\u0435 \u0431\u044b\u0442\u044c. \u041d\u043e, \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435, \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u0438\u043d \u044f\u0437\u044b\u043a \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c. \u0427\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e:  <\/p>\n<ul>\n<li>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u044f\u0437\u044b\u043a\u043e\u0432\u044b\u0435 \u043f\u043e\u043b\u044f \u0432 Post (Header, Content)<\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e CurrentLang, \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0443\u0442 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u044f\u0437\u044b\u043a\u043e\u0432\u044b\u0435 \u043f\u043e\u043b\u044f. <\/li>\n<li>\u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0411\u0414 Post \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0411\u0414 PostLang. <\/li>\n<li>\u041f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0411\u0414, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f, \u043a\u0430\u043a\u043e\u0439 \u0438\u043c\u0435\u043d\u043d\u043e \u044f\u0437\u044b\u043a \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u0438 \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 (\u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430) \u0435\u0449\u0435 \u043d\u0435\u0442, \u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c PostLang \u0432 \u0411\u0414:<\/li>\n<\/ul>\n<p>  \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 (\/Proxy\/Post.cs):  <\/p>\n<pre><code class=\"cs\">public partial class Post     {         private int _currentLang;          public int CurrentLang         {             get             {                 return _currentLang;             }              set             {                 _currentLang = value;                  var currentLang = PostLangs.FirstOrDefault(p =&gt; p.LanguageID == value);                 if (currentLang == null)                 {                     IsCorrectLang = false;                     var anyLang = PostLangs.FirstOrDefault();                     if (anyLang != null)                     {                         SetLang(anyLang);                     }                 }                 else                 {                     IsCorrectLang = true;                     SetLang(currentLang);                 }             }         }          private void SetLang(PostLang postLang)         {             Header = postLang.Header;             Content = postLang.Content;         }          public bool IsCorrectLang { get; protected set; }          public string Header { get; set; }          public string Content { get; set; }     }  <\/code><\/pre>\n<p>  \u0422\u0443\u0442 \u0432\u0430\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u043d\u0435\u0442, \u0442\u043e \u0431\u0435\u0440\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u043f\u0430\u0432\u0448\u0438\u0439\u0441\u044f, \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f IsCorrectLang = false. \u042d\u0442\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0445\u043e\u0442\u044c \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u0447\u0435\u043c \u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0438\u0447\u0435\u0433\u043e. <br \/>  \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435\/\u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 Post (\/SqlRepository\/Post.cs):  <\/p>\n<pre><code class=\"cs\">public bool CreatePost(Post instance)         {             if (instance.ID == 0)             {                 instance.AddedDate = DateTime.Now;                 Db.Posts.InsertOnSubmit(instance);                 Db.Posts.Context.SubmitChanges();                 var lang = Db.Languages.FirstOrDefault(p =&gt; p.ID == instance.CurrentLang);                 if (lang != null)                 {                     CreateOrChangePostLang(instance, null, lang);                     return true;                 }             }              return false;         }          public bool UpdatePost(Post instance)         {             Post cache = Db.Posts.Where(p =&gt; p.ID == instance.ID).FirstOrDefault();             if (cache != null)             {                 cache.Url = instance.Url;                 Db.Posts.Context.SubmitChanges();                  var lang = Db.Languages.FirstOrDefault(p =&gt; p.ID == instance.CurrentLang);                 if (lang != null)                 {                     CreateOrChangePostLang(instance, cache, lang);                     return true;                 }                 return true;             }              return false;         }          private void CreateOrChangePostLang(Post instance, Post cache, Language lang)         {             PostLang postLang = null;             if (cache != null)             {                 postLang = Db.PostLangs.FirstOrDefault(p =&gt; p.PostID == cache.ID && p.LanguageID == lang.ID);             }             if (postLang == null)             {                 var newPostLang = new PostLang()                 {                     PostID = instance.ID,                     LanguageID = lang.ID,                     Header = instance.Header,                     Content = instance.Content,                 };                 Db.PostLangs.InsertOnSubmit(newPostLang);             }             else             {                 postLang.Header = instance.Header;                 postLang.Content = instance.Content;             }             Db.PostLangs.Context.SubmitChanges();         } <\/code><\/pre>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 CreateOrChangePostLang \u0444\u0443\u043d\u043a\u0446\u0438\u044f:   <\/p>\n<ul>\n<li>\u041f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0434\u0430\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043c\u044b \u0438\u0449\u0435\u043c \u0432 Language \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u044f\u0437\u044b\u043a. \u0415\u0441\u043b\u0438 \u044f\u0437\u044b\u043a \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d, \u0442\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u0438 \u043c\u044b \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c PostLang \u043e\u0431\u044a\u0435\u043a\u0442 (\u0442.\u0435. \u043f\u0435\u0440\u0435\u0432\u043e\u0434)<\/li>\n<li>\u0415\u0441\u043b\u0438 \u043c\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u044f\u0437\u044b\u043a, \u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c CreateOrChangePostLang:<br \/> \n<ul>\n<li>\u0415\u0441\u043b\u0438 cache \u043d\u0443\u043b\u0435\u0432\u043e\u0435 (\u043e\u0431\u044a\u0435\u043a\u0442 PostLang \u0435\u0449\u0435 \u0442\u043e\u0447\u043d\u043e \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u043d) \u0438\u043b\u0438 <\/li>\n<li>\u0415\u0441\u043b\u0438 cache \u043d\u0435 \u043d\u0443\u043b\u0435\u0432\u043e\u0435, \u043d\u043e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d, \u0442\u043e <br \/> \n<ul>\n<li>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u0432\u043e\u0434 (\u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0411\u0414 PostLang)<\/li>\n<\/ul>\n<\/li>\n<li> \u0418\u043d\u0430\u0447\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u0432\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0439\u0434\u0435\u043d.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>  \u041f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 Post \u0432\u0441\u0435 PostLang \u0443\u0434\u0430\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u043e \u0441\u0432\u044f\u0437\u0438 OnDelete = cascade (\u043f\u0440\u043e\u0441\u043b\u0435\u0434\u0438\u0442\u0435 \u0437\u0430 \u044d\u0442\u0438\u043c)<br \/>  \u0412 \u0411\u0414 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0443\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u043b\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u044f\u0437\u044b\u043a\u043e\u0432:<\/p>\n<table>\n<tr>\n<td>1<\/td>\n<td>Ru<\/td>\n<td>\u0420\u0443\u0441\u0441\u043a\u0438\u0439<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>En<\/td>\n<td>\u0410\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u0439<\/td>\n<\/tr>\n<\/table>\n<p>  \u0410\u0434\u043c\u0438\u043d\u043a\u0430 <br \/>  \u0421\u0435\u0439\u0447\u0430\u0441, \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0432\u0441\u0451 \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0430\u0434\u043c\u0438\u043d\u043a\u0443. \u041f\u043b\u0430\u043d \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0442\u0430\u043a\u043e\u0432 (\u043c\u044b \u0435\u0433\u043e \u0435\u0449\u0435 \u043f\u043e\u0442\u043e\u043c \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0438 \u043e\u0437\u0432\u0443\u0447\u0438\u043c):  <\/p>\n<ul>\n<li>\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438<\/li>\n<li>\u0421\u0432\u044f\u0437\u0430\u0442\u044c \u044f\u0437\u044b\u043a \u0432\u0432\u043e\u0434\u0430 \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (\u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0432 \u043a\u0430\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440 \u0438\u043b\u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440)<\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u044f\u0437\u044b\u043a\u0430\u043c\u0438<\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u043e\u043c\u0430\u0448\u043d\u044e\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0430\u0434\u043c\u0438\u043d\u043a\u0438<\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043f\u043e\u0441\u0442\u0430\u043c\u0438<\/li>\n<li>\u0412\u044b\u0432\u0435\u0441\u0442\u0438 \u043f\u043e\u0441\u0442\u044b \u0432 default\/postController \u0447\u0430\u0441\u0442\u0438 <\/li>\n<\/ul>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 User LanguageID:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/3d2\/802\/a7e\/3d2802a7ebd6a65c5982a251ed55119a.jpg\"\/><\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 IRepository.cs:  <\/p>\n<pre><code class=\"cs\">bool ChangeLanguage(User instance, string LangCode); <\/code><\/pre>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0432 \/SqlRepository\/User.cs:  <\/p>\n<pre><code class=\"cs\">   public bool ChangeLanguage(User instance, string LangCode)         {             var cache = Db.Users.FirstOrDefault(p =&gt; p.ID == instance.ID);             var newLang = Db.Languages.FirstOrDefault(p =&gt; p.Code == LangCode);             if (cache != null && newLang != null)             {                 cache.Language = newLang;                 Db.Users.Context.SubmitChanges();                 return true;             }              return false;         }  <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c \/Models\/ViewModel\/PostView.cs:  <\/p>\n<pre><code class=\"cs\">public class PostView     {         public int ID { get; set; }          public int UserID { get; set; }          public bool IsCorrectLang { get; set; }          public int CurrentLang { get; set; }          [Required(ErrorMessage = &quot;\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0437\u0430\u043b\u043e\u0433\u043e\u0432\u043e\u043a&quot;)]         public string Header { get; set; }          [Required]         public string Url { get; set; }          [Required(ErrorMessage = &quot;\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435&quot;)]         public string Content { get; set; }     }  <\/code><\/pre>\n<p>  \u0421\u0442\u0440\u043e\u043a\u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u043d\u0435 \u043d\u0430\u0434\u043e \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432 GlobalRes, \u0442\u0430\u043a \u043a\u0430\u043a \u0442\u0443\u0442 \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0430\u0434\u043c\u0438\u043d\u043a\u0435 \u0438 \u044d\u0442\u043e \u043d\u0430\u043c \u043d\u0438 \u043a \u0447\u0435\u043c\u0443 (\u0442\u0430\u043a \u043a\u0430\u043a \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u044b \u043b\u044e\u0434\u0438 \u0441\u043a\u0440\u043e\u043c\u043d\u044b\u0435). \u041d\u043e \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f, \u0442\u043e \u043c\u044b \u0437\u043d\u0430\u0435\u043c \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c.<br \/>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \/Areas\/Admin\/Controller\/AdminController.cs:  <\/p>\n<pre><code class=\"cs\">public abstract class AdminController : BaseController     {         public Language CurrentLang         {             get             {                 return CurrentUser != null ? CurrentUser.Language : null;             }         }          protected override void Initialize(RequestContext requestContext)         {             CultureInfo ci = new CultureInfo(&quot;ru&quot;);              Thread.CurrentThread.CurrentCulture = ci;             base.Initialize(requestContext);         }      } <\/code><\/pre>\n<p>  \u0418 \/Areas\/Admin\/Controller\/HomeController.cs:  <\/p>\n<pre><code class=\"cs\">[Authorize(Roles=&quot;admin&quot;)]     public class HomeController : AdminController     {         public ActionResult Index()         {             return View();         }          public ActionResult AdminMenu()         {             return View();         }          public ActionResult LangMenu()         {             if (CurrentLang == null)             {                 var lang = repository.Languages.FirstOrDefault();                 repository.ChangeLanguage(currentUser, lang.Code);             }             var langProxy = new LangAdminView(repository, CurrentLang.Code);             return View(langProxy);         }          [HttpPost]         public ActionResult ChangeLanguage(string SelectedLang)         {             repository.ChangeLanguage(currentUser, SelectedLang);             return Redirect(&quot;~\/admin&quot;);         }     }  <\/code><\/pre>\n<p>  \u0418\u0442\u0430\u043a, AdminController \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442, \u0432 \u043a\u0430\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435 \u043c\u044b \u0441\u0435\u0439\u0447\u0430\u0441 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c. \u0415\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0439 \u044f\u0437\u044b\u043a \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d, \u0442\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u043f\u0430\u0432\u0448\u0438\u0439\u0441\u044f, \u0438 \u0432 HomeController.cs:LangMenu \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c LangAdminView.cs (\/Models\/ViewModel\/LangAdminView.cs):  <\/p>\n<pre><code class=\"cs\">public class LangAdminView     {         private IRepository Repository         {             get             {                 return DependencyResolver.Current.GetService&lt;IRepository&gt;();             }         }          public string SelectedLang {get; set; }          public List&lt;SelectListItem&gt; Langs { get; set; }          public LangAdminView(string currentLang)         {             currentLang = currentLang ?? &quot;&quot;;             Langs = new List&lt;SelectListItem&gt;();              foreach (var lang in Repository.Languages)             {                 Langs.Add(new SelectListItem()                 {                     Selected = (string.Compare(currentLang, lang.Code, true) == 0),                     Value = lang.Code,                     Text = lang.Name                 });             }         }     }  <\/code><\/pre>\n<p>   \u041e\u043f\u0438\u0448\u0435\u043c \u0432\u0441\u0435 View (+js-\u0444\u0430\u0439\u043b\u044b):<br \/>  \/Areas\/Admin\/Views\/Shared\/_Layout.cshtml:  <\/p>\n<pre><code class=\"html\">@{     var currentUser = ((LessonProject.Controllers.BaseController)ViewContext.Controller).CurrentUser; } &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt;     &lt;title&gt;@ViewBag.Title&lt;\/title&gt;     &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text\/html;charset=UTF-8&quot; \/&gt;     @Styles.Render(&quot;~\/Content\/css\/jqueryui&quot;)     @Styles.Render(&quot;~\/Content\/css&quot;)     @RenderSection(&quot;styles&quot;, required: false)     @Scripts.Render(&quot;~\/bundles\/modernizr&quot;) &lt;\/head&gt; &lt;body&gt;     &lt;div class=&quot;navbar navbar-fixed-top&quot;&gt;         &lt;div class=&quot;navbar-inner&quot;&gt;             &lt;div class=&quot;container-fluid&quot;&gt;                 &lt;div class=&quot;btn-group pull-right&quot;&gt;                     &lt;a class=&quot;btn dropdown-toggle&quot; data-toggle=&quot;dropdown&quot; href=&quot;#&quot;&gt;&lt;i class=&quot;icon-user&quot;&gt;                     &lt;\/i&gt;                         @currentUser.Email&lt;span class=&quot;caret&quot;&gt;&lt;\/span&gt;                     &lt;\/a&gt;                     &lt;ul class=&quot;dropdown-menu&quot;&gt;                         &lt;li&gt;&lt;a href=&quot;\/&quot;&gt;\u041d\u0430 \u0441\u0430\u0439\u0442&lt;\/a&gt;&lt;\/li&gt;                         &lt;li class=&quot;divider&quot;&gt;&lt;\/li&gt;                         &lt;li&gt;&lt;a href=&quot;@Url.Action(&quot;Logout&quot;, &quot;Login&quot;, new { area = &quot;Default&quot; })&quot;&gt;\u0412\u044b\u0445\u043e\u0434&lt;\/a&gt;                         &lt;\/li&gt;                     &lt;\/ul&gt;                 &lt;\/div&gt;                 &lt;a class=&quot;brand&quot; href=&quot;@Url.Action(&quot;Index&quot;, &quot;Home&quot;)&quot;&gt;LessonProject&lt;\/a&gt;             &lt;\/div&gt;         &lt;\/div&gt;     &lt;\/div&gt;     &lt;div class=&quot;container-fluid&quot;&gt;         &lt;div class=&quot;row-fluid&quot;&gt;             &lt;div class=&quot;span3&quot;&gt;                 &lt;div class=&quot;well sidebar-nav&quot;&gt;                     &lt;ul class=&quot;nav nav-list&quot;&gt;                         @Html.Action(&quot;LangMenu&quot;, &quot;Home&quot;)                         @Html.Action(&quot;AdminMenu&quot;, &quot;Home&quot;)                     &lt;\/ul&gt;                 &lt;\/div&gt;             &lt;\/div&gt;             &lt;div class=&quot;span9&quot;&gt;                 @RenderBody()             &lt;\/div&gt;         &lt;\/div&gt;     &lt;\/div&gt;     @Scripts.Render(&quot;~\/bundles\/jquery&quot;)     @Scripts.Render(&quot;~\/bundles\/jqueryui&quot;)     @Scripts.Render(&quot;~\/bundles\/bootstrap&quot;)     @Scripts.Render(&quot;~\/bundles\/common&quot;)     @Scripts.Render(&quot;\/Scripts\/admin\/common.js&quot;)     @RenderSection(&quot;scripts&quot;, required: false) &lt;\/body&gt; &lt;\/html&gt; <\/code><\/pre>\n<p>  Index.cshtml (\/Areas\/Admin\/Views\/Home\/Index.cshtml):  <\/p>\n<pre><code class=\"html\">@{     ViewBag.Title = &quot;Index&quot;;     Layout = &quot;~\/Areas\/Admin\/Views\/Shared\/_Layout.cshtml&quot;; }  &lt;h2&gt;\u0410\u0434\u043c\u0438\u043d\u043a\u0430&lt;\/h2&gt;  AdminMenu.cshtml (\/Areas\/Admin\/Views\/Home\/AdminMenu.cshtml): &lt;li&gt;     @Html.ActionLink(&quot;\u0413\u043b\u0430\u0432\u043d\u0430\u044f&quot;, &quot;Index&quot;, &quot;Home&quot;) &lt;\/li&gt; &lt;li&gt;     @Html.ActionLink(&quot;\u041f\u043e\u0441\u0442\u044b&quot;, &quot;Index&quot;, &quot;Post&quot;) &lt;\/li&gt; <\/code><\/pre>\n<p>  LangMenu.cshtml (\/Areas\/Admin\/Views\/Home\/LangMenu.cshtml):  <\/p>\n<pre><code class=\"html\">@model LessonProject.Models.ViewModels.LangAdminView  &lt;li&gt;     @using (Html.BeginForm(&quot;ChangeLanguage&quot;, &quot;Home&quot;, FormMethod.Post, new { id = &quot;SelectLangForm&quot; }))     {         @Html.DropDownList(&quot;SelectedLang&quot;, Model.Langs)     } &lt;\/li&gt; <\/code><\/pre>\n<p>  \u0418 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a SelectedLang (\/Scripts\/admin\/common.js):  <\/p>\n<pre><code class=\"javascript\">function AdminCommon() {     _this = this;      this.init = function ()     {         $(&quot;#SelectedLang&quot;).change(function () {             $(&quot;#SelectLangForm&quot;).submit();         });     } }  var adminCommon = null; $().ready(function () {     adminCommon = new AdminCommon();     adminCommon.init(); }); <\/code><\/pre>\n<p>  \u2003<br \/>  \u0417\u0430\u0445\u043e\u0434\u0438\u043c \u043f\u043e\u0434 \u0430\u0434\u043c\u0438\u043d\u043e\u043c (\u0443 \u043c\u0435\u043d\u044f \u044d\u0442\u043e chernikov@gmail.com) \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 <a href=\"http:\/\/localhost\/admin\">localhost\/admin<\/a>:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/777\/3df\/c7c\/7773dfc7ca0594ebff36d35f46cd0ba0.jpg\"\/><\/p>\n<p>  <i>\u0415\u0441\u043b\u0438 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0437\u0430\u0439\u0442\u0438 \u0438 \u0432\u044b\u043a\u0438\u043d\u0443\u043b\u043e \u043d\u0430 \/Login, \u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435 \u0441\u0432\u044f\u0437\u044c UserRole \u0432 \u0411\u0414, \u0447\u0442\u043e\u0431\u044b \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0438\u043c\u0435\u043b \u0440\u043e\u043b\u044c \u0441 \u043a\u043e\u0434\u043e\u043c \u201cadmin\u201d.<\/i><\/p>\n<p>  \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u044f\u0437\u044b\u043a\u043e\u0432. \u041e\u043d \u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0432 \u043a\u0430\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435 \u043c\u044b \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c.<br \/>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 PostController.cs (\/Areas\/Admin\/Controllers\/PostController.cs):  <\/p>\n<pre><code class=\"cs\">public class PostController : AdminController     {         public ActionResult Index(int page = 1)         {             var list = Repository.Posts.OrderByDescending(p =&gt; p.AddedDate);             var data = new PageableData&lt;Post&gt;(list, page);             data.List.ForEach(p =&gt; p.CurrentLang = CurrentLang.ID);             return View(data);         }  [HttpGet]         public ActionResult Create()         {             var postView = new PostView              {                 CurrentLang = CurrentLang.ID             };             return View(&quot;Edit&quot;, postView);         }           [HttpGet]         public ActionResult Edit(int id)         {             var post = Repository.Posts.FirstOrDefault(p =&gt; p.ID == id);             if (post != null)             {                 post.CurrentLang = CurrentLang.ID;                 var postView = (PostView)ModelMapper.Map(post, typeof(Post), typeof(PostView));                 return View(postView);             }             return RedirectToNotFoundPage;         }          [HttpPost]         [ValidateInput(false)]         public ActionResult Edit(PostView postView)         {             if (ModelState.IsValid)             {                 var post = (Post)ModelMapper.Map(postView, typeof(PostView), typeof(Post));                 post.CurrentLang = CurrentLang.ID;                 if (post.ID == 0)                 {                     post.UserID = CurrentUser.ID;                     Repository.CreatePost(post);                 }                 else                 {                     Repository.UpdatePost(post);                 }                 TempData[&quot;Message&quot;] = &quot;\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043e!&quot;;                 return RedirectToAction(&quot;Index&quot;);             }             return View(postView);         }          public ActionResult Delete(int id)         {             Repository.RemovePost(id);             TempData[&quot;Message&quot;] = &quot;\u0423\u0434\u0430\u043b\u0435\u043d \u043f\u043e\u0441\u0442&quot;;              return RedirectToAction(&quot;Index&quot;);         }     } <\/code><\/pre>\n<p>  \u0418\u0437\u043c\u0435\u043d\u0438\u043c PageableData, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c Foreach (\/Models\/Info\/PageableData.cs):   <\/p>\n<pre><code class=\"cs\">  public class PageableData&lt;T&gt; where T : class     {         protected static int ItemPerPageDefault = 20;          public List&lt;T&gt; List { get; set; } \u2026 public PageableData(IQueryable&lt;T&gt; queryableSet, int page, int itemPerPage = 0)         { \u2026 List = queryableSet.Skip((PageNo - 1) * itemPerPage).Take(itemPerPage).ToList();         }     }  <\/code><\/pre>\n<p>  Index.cshtml (\/Areas\/Admin\/Views\/Post\/Index.cshtml):  <\/p>\n<pre><code class=\"html\">@model LessonProject.Models.Info.PageableData&lt;LessonProject.Model.Post&gt;  @{     ViewBag.Title = &quot;\u041f\u043e\u0441\u0442\u044b&quot;;     Layout = &quot;~\/Areas\/Admin\/Views\/Shared\/_Layout.cshtml&quot;; }  &lt;h2&gt;     \u041f\u043e\u0441\u0442\u044b &lt;\/h2&gt; @Html.ActionLink(&quot;\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c&quot;, &quot;Create&quot;, &quot;Post&quot;, null, new { @class = &quot;btn&quot; }) &lt;table class=&quot;table&quot;&gt;     &lt;thead&gt;         &lt;tr&gt;             &lt;th&gt;                 #             &lt;\/th&gt;             &lt;th&gt;             \u043f\u0435\u0440\u0435\u0432\u043e\u0434             &lt;\/th&gt;             &lt;th&gt;                 \u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435             &lt;\/th&gt;                          &lt;th&gt;             &lt;\/th&gt;         &lt;\/tr&gt;     &lt;\/thead&gt;     @foreach (var item in Model.List)     {         &lt;tr&gt;             &lt;td&gt;                 @item.ID             &lt;\/td&gt;             &lt;td&gt;             @(item.IsCorrectLang ? &quot;&quot; : &quot;\u043d\u0443\u0436\u0435\u043d \u043f\u0435\u0440\u0435\u0432\u043e\u0434&quot;)             &lt;\/td&gt;             &lt;td&gt;                 @item.Header             &lt;\/td&gt;             &lt;td&gt;                 @Html.ActionLink(&quot;\u0418\u0437\u043c\u0435\u043d\u0438\u0442\u044c&quot;, &quot;Edit&quot;, &quot;Post&quot;, new { id = item.ID }, new { @class = &quot;btn  btn-mini&quot; })                 @Html.ActionLink(&quot;\u0423\u0434\u0430\u043b\u0438\u0442\u044c&quot;, &quot;Delete&quot;, &quot;Post&quot;, new { id = item.ID }, new { @class = &quot;btn  btn-mini btn-danger&quot; })             &lt;\/td&gt;         &lt;\/tr&gt;     } &lt;\/table&gt; <\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 ForEach, \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0435 \u0443\u0436\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u044f\u0437\u044b\u043a\u043e\u0432\u044b\u0435 \u043f\u043e\u043b\u044f. \u042f\u0437\u044b\u043a \u2013 \u0442\u043e\u0442, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0432 \u0430\u0434\u043c\u0438\u043d\u043a\u0435. <br \/>  View \u0434\u043b\u044f \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0432\u0441\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0434\u0435\u043b\u0430\u0435\u043c \u0432 Controller, \u0430 \u043d\u0430\u0448 PostView \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u044f\u0437\u044b\u043a\u043e\u0432\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438. (\/Areas\/Admin\/Views\/Post\/Edit.cshtml):  <\/p>\n<pre><code class=\"html\">@model LessonProject.Models.ViewModels.PostView  @{     ViewBag.Title = Model.ID == 0 ? &quot;\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0441\u0442&quot; : &quot;\u0418\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u043e\u0441\u0442&quot;;     Layout = &quot;~\/Areas\/Admin\/Views\/Shared\/_Layout.cshtml&quot;; }  &lt;h2&gt;@(Model.ID == 0 ? &quot;\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0441\u0442&quot; : &quot;\u0418\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u043e\u0441\u0442&quot;)&lt;\/h2&gt; &lt;p&gt; &lt;\/p&gt; @using (Html.BeginForm(&quot;Edit&quot;, &quot;Post&quot;, FormMethod.Post)) {     @Html.Hidden(&quot;ID&quot;, Model.ID)     &lt;fieldset&gt;            &lt;div class=&quot;control-group&quot;&gt;             &lt;label class=&quot;control-label&quot;&gt;              @(!Model.IsCorrectLang && Model.ID != 0 ? &quot;\u043d\u0443\u0436\u0435\u043d \u043f\u0435\u0440\u0435\u0432\u043e\u0434&quot; : &quot;&quot;)             &lt;\/label&gt;         &lt;\/div&gt;         &lt;div class=&quot;control-group&quot;&gt;             &lt;label class=&quot;control-label&quot;&gt;                 \u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a&lt;\/label&gt;             &lt;div class=&quot;controls&quot;&gt;                 @Html.TextBox(&quot;Header&quot;, Model.Header, new { @class = &quot;input-xlarge&quot; })                 @Html.ValidationMessage(&quot;Header&quot;)             &lt;\/div&gt;         &lt;\/div&gt;         &lt;div class=&quot;control-group&quot;&gt;             &lt;label class=&quot;control-label&quot;&gt;                 Url&lt;\/label&gt;             &lt;div class=&quot;controls&quot;&gt;                 @Html.TextBox(&quot;Url&quot;, Model.Url, new { @class = &quot;input-xlarge&quot; })                 @Html.ValidationMessage(&quot;Url&quot;)             &lt;\/div&gt;         &lt;\/div&gt;          &lt;div class=&quot;control-group&quot;&gt;             &lt;label class=&quot;control-label&quot;&gt;                 \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435&lt;\/label&gt;             &lt;div class=&quot;controls&quot;&gt;                 @Html.TextArea(&quot;Content&quot;, Model.Content, new { @class = &quot;input-xlarge&quot; })                 @Html.ValidationMessage(&quot;Content&quot;)             &lt;\/div&gt;         &lt;\/div&gt;         &lt;div class=&quot;form-actions&quot;&gt;             &lt;button type=&quot;submit&quot; class=&quot;btn btn-primary&quot;&gt;                 \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c&lt;\/button&gt;             @Html.ActionLink(&quot;\u041e\u0442\u043c\u0435\u043d\u0438\u0442\u044c&quot;, &quot;Index&quot;, null, null, new { @class = &quot;btn&quot; })         &lt;\/div&gt;     &lt;\/fieldset&gt; } <\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0443 \u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043f\u043e\u043b\u044f \u0443\u0436\u0435 \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u044b, \u0438 \u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u043f\u0435\u0440\u0435\u0432\u043e\u0434.<br \/>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0430\u0440\u0443 \u043f\u043e\u0441\u0442\u043e\u0432 \u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u0438\u0445:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/260\/344\/96b\/26034496b54986e3e5cd541f675d1071.jpg\"\/><\/p>\n<p>  \u041e\u043a, \u043f\u043e\u0441\u0442\u044b \u0441\u043e\u0437\u0434\u0430\u043d\u044b.<br \/>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c PostController \u0432 Default Area \u0438 \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u043f\u043e\u0441\u0442\u044b (\/Areas\/Default\/Controller\/PostController.cs):  <\/p>\n<pre><code class=\"cs\">public class PostController : DefaultController     {         public ActionResult Index(int page = 1)         {             var list = Repository.Posts.OrderByDescending(p =&gt; p.AddedDate);             var data = new PageableData&lt;Post&gt;(list, page);             data.List.ForEach(p =&gt; p.CurrentLang = CurrentLang.ID);             return View(data);         }     } <\/code><\/pre>\n<p>  \u2003<br \/>  Index.cshtml (\/Areas\/Default\/Views\/Post\/Index.cshtml):  <\/p>\n<pre><code class=\"html\">@model LessonProject.Models.Info.PageableData&lt;LessonProject.Model.Post&gt;  @{     ViewBag.Title = &quot;Index&quot;;     Layout = &quot;~\/Areas\/Default\/Views\/Shared\/_Layout.cshtml&quot;; }   &lt;div class=&quot;item&quot;&gt; @foreach (var post in Model.List) {     &lt;h3&gt;@post.Header&lt;\/h3&gt;     &lt;p&gt;         @post.Content.NlToBr()     &lt;\/p&gt;     &lt;span&gt;@post.AddedDate.ToString(&quot;d&quot;)&lt;\/span&gt; } &lt;\/div&gt; &lt;div class=&quot;pagination&quot;&gt;     @Html.PageLinks(Model.PageNo, Model.CountPage, x =&gt; Url.Action(&quot;Index&quot;, new {page = x})) &lt;\/div&gt; <\/code><\/pre>\n<p>  \u0418 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/330\/646\/50e\/33064650ec7150df1cccbdfc6795d212.jpg\"\/><\/p>\n<p>  \u0421\u0443\u043f\u0435\u0440!<\/p>\n<h5>\u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u044f\u0437\u044b\u043a\u0430\u043c\u0438<\/h5>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u043b\u043a\u0443 ru\/en \u0432 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u0438. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043b\u0430\u0441\u0441 LangHelper.cs (\/Helper\/LangHelper.cs):  <\/p>\n<pre><code class=\"cs\">public static class LangHelper     {         public static MvcHtmlString LangSwitcher(this UrlHelper url, string Name, RouteData routeData, string lang)         {             var liTagBuilder = new TagBuilder(&quot;li&quot;);             var aTagBuilder = new TagBuilder(&quot;a&quot;);             var routeValueDictionary = new RouteValueDictionary(routeData.Values);             if (routeValueDictionary.ContainsKey(&quot;lang&quot;))             {                 if (routeData.Values[&quot;lang&quot;] as string == lang)                 {                     liTagBuilder.AddCssClass(&quot;active&quot;);                 }                 else                 {                     routeValueDictionary[&quot;lang&quot;] = lang;                 }             }             aTagBuilder.MergeAttribute(&quot;href&quot;, url.RouteUrl(routeValueDictionary));             aTagBuilder.SetInnerText(Name);             liTagBuilder.InnerHtml = aTagBuilder.ToString();             return new MvcHtmlString(liTagBuilder.ToString());         }     }  <\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c Partial \u0432 _Layout.cshtml (\/Areas\/Default\/Views\/Shared\/_Layout.cshtml):<br \/>  &lt;<\/p>\n<pre><code class=\"html\">div class=&quot;container&quot;&gt;                 &lt;ul class=&quot;nav nav-pills pull-right&quot;&gt;                     @Html.Partial(&quot;LangMenu&quot;)                 &lt;\/ul&gt; <\/code><\/pre>\n<p>  + LangMenu.cshtml:   <\/p>\n<pre><code class=\"html\">@Url.LangSwitcher(&quot;en&quot;, ViewContext.RouteData, &quot;en&quot;) @Url.LangSwitcher(&quot;ru&quot;, ViewContext.RouteData, &quot;ru&quot;) <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c. \u0412\u0443\u0430\u043b\u044f! \u041a\u0440\u0430\u0441\u043e\u0442\u0430.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/268\/819\/8d4\/2688198d43eea667d67122427bcb8360.jpg\"\/><\/p>\n<p>  \u041d\u0435\u0432\u0435\u0440\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442, \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u0438\u0439<br \/>  \u0418\u043d\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0432\u0432\u043e\u0434\u0438\u043c \u0432 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0435 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0435 \u043f\u043e\u043b\u0435 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0442\u043e \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435:  <\/p>\n<pre><code>The value 'one hundred dollars' is not valid for Price. <\/code><\/pre>\n<p>  \u041d\u043e \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c:  <\/p>\n<ul>\n<li>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0430\u043f\u043a\u0443 App_GlobalResources <\/li>\n<li>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441 Messages.resx<\/li>\n<li>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u201cPropertyValueInvalid: <b>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 {0} \u043d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u044f {1}<\/b>\u201d<\/li>\n<li>\u0412 App_Start \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 Application_Start() (\/Global.asax.cs)<\/li>\n<li>DefaultModelBinder.ResourceClassKey = \u00abMessages\u00bb;<\/li>\n<li>\u0414\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044f \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442 Display[Name=\u201d\u0426\u0435\u043d\u0430\u201d] <\/li>\n<li>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/ded\/c61\/168\/dedc611684cc644f5766dcbac023cfbe.jpg\"\/><\/li>\n<\/ul>\n<h5>\u0418\u0442\u043e\u0433<\/h5>\n<p>  \u0420\u0430\u0431\u043e\u0442\u0430 \u0432 \u043c\u043d\u043e\u0433\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u043c \u0441\u0430\u0439\u0442\u0435 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u0449\u0435\u043c:  <\/p>\n<ul>\n<li>\u041e\u0442\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0440\u0435\u0441\u0443\u0440\u0441\u044b <\/li>\n<li>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u044f\u0437\u044b\u043a\u043e\u0432\u044b\u0435 \u043f\u043e\u043b\u044f \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 \u0411\u0414 \u0438 \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0438\u0445 \u0447\u0435\u0440\u0435\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 Language<\/li>\n<li>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c ajax-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u044f\u0437\u044b\u043a\u043e\u0432\u043e\u0439 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438<\/li>\n<\/ul>\n<p>  \u041d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a \u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u0439 \u0441\u0430\u0439\u0442, \u0435\u0441\u043b\u0438 \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a \u044f\u0432\u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u0442, \u043d\u043e, \u0435\u0441\u043b\u0438 \u0432 \u043e\u0431\u043e\u0437\u0440\u0438\u043c\u043e\u043c \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u0430\u043a\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c, \u0442\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u0430\u0439\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u043d\u043e\u0433\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u0441\u0442\u0438, \u0445\u043e\u0442\u044f \u0431\u044b \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0411\u0414.<\/p>\n<p>  \u0412\u0441\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <a href=\"https:\/\/bitbucket.org\/chernikov\/lessons\">https:\/\/bitbucket.org\/chernikov\/lessons<\/a>    \t \t\t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/176095\/\"> http:\/\/habrahabr.ru\/post\/176095\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t<b>\u0426\u0435\u043b\u044c \u0443\u0440\u043e\u043a\u0430.<\/b> \u041d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u0435 \u0441\u0430\u0439\u0442\u044b. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0411\u0414. \u0420\u0435\u0441\u0443\u0440\u0441\u044b \u0441\u0430\u0439\u0442\u0430. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u044f\u0437\u044b\u043a\u0430. \u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u044f\u0437\u044b\u043a\u0430\u043c\u0438. \u0420\u0430\u0431\u043e\u0442\u0430 \u0432 \u0430\u0434\u043c\u0438\u043d\u043a\u0435.<\/p>\n<h5>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043c\u043d\u043e\u0433\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u0433\u043e \u0441\u0430\u0439\u0442\u0430<\/h5>\n<p>  \u0418\u0442\u0430\u043a, \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a \u043f\u0440\u043e\u0441\u0438\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0430\u0439\u0442 \u043c\u043d\u043e\u0433\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u043c, \u0442.\u0435. \u0447\u0442\u043e\u0431\u044b \u0438 \u043f\u043e-\u0440\u0443\u0441\u0441\u043a\u0438, \u0438 \u043f\u043e-\u0444\u0440\u0430\u043d\u0446\u0443\u0437\u043a\u0438, \u0438 \u043f\u043e-\u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043a\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u043d\u043e\u0433\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u0439 \u0431\u043b\u043e\u0433, \u0442\u0430\u043a \u0438 \u0433\u043e\u0441\u0442\u0438\u043d\u0438\u0447\u043d\u044b\u0439 \u0441\u0430\u0439\u0442, \u0441\u0430\u0439\u0442 \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043d\u0435\u0434\u0432\u0438\u0436\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435. <br \/>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c, \u0447\u0442\u043e \u0436\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c:  <\/p>\n<ul>\n<li>\u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0434\u0430\u0442, \u0441\u0443\u043c\u043c \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0421 \u044d\u0442\u0438\u043c \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441 System.Globalization<\/li>\n<li>\u0412\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0441\u0430\u0439\u0442\u0430 \u2014 \u0432\u044b\u0434\u0430\u0447\u0430 \u043e\u0448\u0438\u0431\u043a\u0438 (\u00ab\u041f\u043e\u043b\u0435 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0443\u0441\u0442\u044b\u043c\u00bb, \u00abThe field is required\u00bb) \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f.<\/li>\n<li>\u041d\u0435 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b, \u043a\u0430\u043a \u0442\u043e \u043b\u043e\u0433\u043e\u0442\u0438\u043f\u044b, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, js-\u043b\u043e\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u043d\u0430\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044f\u0437\u044b\u043a\u0430 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435.<\/li>\n<li>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. <\/li>\n<\/ul>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-176095","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/176095","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=176095"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/176095\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=176095"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=176095"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=176095"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}