{"id":176001,"date":"2013-04-09T22:58:04","date_gmt":"2013-04-09T18:58:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=176001"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=176001","title":{"rendered":"<span class=\"post_title\">ASP.NET MVC \u0423\u0440\u043e\u043a 1. \u041d\u0430\u0447\u0430\u043b\u043e<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t<b>\u0426\u0435\u043b\u044c \u0443\u0440\u043e\u043a\u0430:<\/b> \u0418\u0437\u0443\u0447\u0438\u0442\u044c Global.asax \u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0435\u0431-\u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0418\u0437\u0443\u0447\u0435\u043d\u0438\u0435 Nuget \u0438 \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<h5>\u041d\u0430\u0447\u0430\u043b\u043e<\/h5>\n<p>   \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 ASP.NET MVC 4 Web Application \u00abLesson1\u00bb (\u0440\u0438\u0441 1.):<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/ab8\/247\/78f\/ab824778ffc23afca87e93b7295e7ffe.jpg\"\/><\/p>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/bb5\/1d0\/335\/bb51d0335feaff42704b5f81bd29b8ff.jpg\"\/><\/p>\n<p>  \u041d\u0435 \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0430 \u0441\u0440\u0430\u0437\u0443 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c (\u0435\u0441\u043b\u0438 \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u043b\u0438) NuGet \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/41a\/823\/53f\/41a82353fd83ff2276f181bc37f78c46.jpg\"\/><\/p>\n<p>  NuGet Package Manager \u2013 \u044d\u0442\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0434\u043b\u044f Visual Studio, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b \u043c\u043e\u0434\u0443\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u044e\u0442 \u0440\u0430\u0431\u043e\u0442\u0443. \u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u00abBasic\u00bb asp.net mvc4 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u0441\u0430\u043c\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u044b\u043b\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u0435\u0439. \u0418\u0445 \u0441\u043f\u0438\u0441\u043e\u043a \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0439\u0442\u0438, \u043a\u043b\u0438\u043a\u043d\u0443\u0432 \u0432 Manage NuGet Packages\u2026 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u043e\u043c \u043c\u0435\u043d\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0430:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/2d6\/69f\/7fb\/2d669f7fb8c8c72bad66e5a15286a62d.jpg\"\/><\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/b43\/b1f\/59f\/b43b1f59f00184f4e5683825fd4d1a01.jpg\"\/><\/p>\n<p>  \u041e \u043d\u0438\u0445 \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443:<\/p>\n<ul>\n<li><b>Entity Framework<\/b> \u2013 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0411\u0414 <\/li>\n<li><b>jQuery (+ jQuery UI, jQuery Validation)<\/b> \u2013 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0439 javascript framework (\u043e \u043d\u0435\u043c \u0435\u0449\u0435 \u043f\u043e\u0439\u0434\u0435\u0442 \u0440\u0435\u0447\u044c \u043f\u043e\u0437\u0436\u0435).<\/li>\n<li><b>Json.NET<\/b> \u2013 \u043a\u043b\u0430\u0441\u0441\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 json-\u0444\u043e\u0440\u043c\u0430\u0442\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445.<\/li>\n<li><b>knockoutjs<\/b> \u2013 javascript \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Model View ViewModel \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043e\u0439. (<a href=\"http:\/\/knockoutjs.com\/\">http:\/\/knockoutjs.com\/<\/a>)<\/li>\n<li><b>Microsoft.Net Framework 4 Http Client Libraries<\/b> \u2013 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 HttpContext-\u043e\u043c. <\/li>\n<li><b>Microsoft ASP.NET MVC 4<\/b> \u2013 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043a\u043b\u0430\u0441\u0441\u044b \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f MVC (\u0442\u043e, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u043c \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f)<\/li>\n<li><b>Microsoft ASP.NET Razor 2<\/b> \u2013 view-\u0434\u0432\u0438\u0436\u043e\u043a. \u0415\u0441\u0442\u044c \u0435\u0449\u0435 ASPX \u0438 Spark \u2013 \u043c\u044b \u043e \u043d\u0438\u0445 \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u043c \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043f\u043e\u0437\u0436\u0435<\/li>\n<li><b>Microsoft ASP.NET Universal Providers Core Libraries (Microsoft ASP.NET Universal Providers for LocalDB)<\/b> \u2013 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0432\u0441\u0435\u0445 SQL Server 2005 (\u0438 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0437\u0434\u043d\u0438\u0445) \u0438 \u0434\u043b\u044f SQL Azure.<\/li>\n<li><b>Microsoft ASP.NET Web API (Microsoft ASP.NET Web API Client Libraries, Microsoft ASP.NET Web API Core Libraries, Microsoft ASP.NET Web API Web Host)<\/b> \u2013 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f REST \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 XML, JSON \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435<\/li>\n<li><b>Microsoft ASP.NET Web Optimization Framework<\/b> \u2013 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442 js-\u043a\u043e\u0434<\/li>\n<li><b>Microsoft ASP.NET WebPages 2<\/b> \u2013 \u043d\u0430\u0431\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u043e View<\/li>\n<li><b>Microsoft jQuery Unobtrusive Ajax (Microsoft jQuery Unobtrusive Validation)<\/b> \u2013 jQuery \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u043d\u0435\u043d\u0430\u0432\u044f\u0449\u0435\u0432\u043e\u0439 ajax\/\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438<\/li>\n<li><b>Microsoft.Web.Infrastructure<\/b> \u2013 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c HTTP-\u043c\u043e\u0434\u0443\u043b\u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/li>\n<li><b>Modernizr<\/b> \u2013 js-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c html5 \u0438 css3 \u0432 \u0441\u0442\u0430\u0440\u044b\u0445 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430\u0445<\/li>\n<li><b>WebGrease<\/b> \u2013 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043c\u0438\u043d\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c html, css, js.<\/li>\n<\/ul>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043f\u0440\u0438\u043a\u0438\u043d\u0443\u043b\u0438, \u0438\u0437 \u0447\u0435\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0435\u0433\u043e. <br \/>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c HomeController:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/17f\/e71\/d62\/17fe71d62a1d4504f0f809c6a7f8c70c.jpg\"\/><\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/29d\/9ba\/d2e\/29d9bad2e6969dff4c6c975070c5004c.jpg\"\/><\/p>\n<p>  \u0414\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u0430 (\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f) Index \u0434\u043e\u0431\u0430\u0432\u0438\u043c View \u0438 \u0432\u044b\u0431\u0435\u0440\u0435\u043c ~Views\/Shared\/_Layout.cshtml \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 layout (\u0442\u0438\u043f\u0430 master page):<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/187\/ba5\/42d\/187ba542d3ce1005e00ff350d5a59f5f.jpg\"\/><\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/56f\/0f6\/849\/56f0f684990ce0ac9f0a0689ee5e4808.jpg\"\/><\/p>\n<p>  \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c.<br \/>  \u0412\u0441\u0451 \u0447\u0442\u043e \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u2013 \u044d\u0442\u043e:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/778\/79b\/2a3\/77879b2a3bbf19b1869801b09cf38aa8.jpg\"\/><\/p>\n<p>  \u041f\u043e\u0447\u0435\u043c\u0443 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043d\u0430\u0434\u043e \u0431\u044b\u043b\u043e \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e Home \u0438 \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0443\u0440\u043e\u043a\u0430\u0445. <\/p>\n<h5>Global.asax<\/h5>\n<p>  \u0410 \u0441\u0435\u0439\u0447\u0430\u0441 \u043e\u0431\u0440\u0430\u0442\u0438\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0444\u0430\u0439\u043b Global.asax:<\/p>\n<pre><code class=\"cs\">public class MvcApplication : System.Web.HttpApplication     {         protected void Application_Start()         {             AreaRegistration.RegisterAllAreas();              FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);             RouteConfig.RegisterRoutes(RouteTable.Routes);             BundleConfig.RegisterBundles(BundleTable.Bundles);         }     } <\/code><\/pre>\n<p>  \u041a\u043b\u0430\u0441\u0441 MvcApplication \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442 HttpApplication \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0415\u0441\u0442\u044c \u0435\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0434. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438\u0445:<\/p>\n<ul>\n<li><b>public void Init() <\/b>\u2013 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438\u043b\u0438 \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435. \u041e\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 HttpApplication.<\/li>\n<li><b>public void Dispose()<\/b> \u2013 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u0434 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430 HttpApplication. \u042d\u0442\u043e \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u0434\u043b\u044f \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0440\u0430\u043d\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432.<\/li>\n<li><b>Application_Error<\/b> \u2013 \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u043e\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438.<\/li>\n<li><b>Application_Start <\/b>\u2013 \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 HttpApplication \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430 HttpApplication.<\/li>\n<li><b>Application_End<\/b> \u2013 \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0440\u0430\u043d\u0435\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u043a\u043b\u0430\u0441\u0441\u0430 HttpApplication \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0435\u043d\u044b. \u042d\u0442\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0430\u0436\u0434\u044b \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0436\u0438\u0437\u043d\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/li>\n<li><b>Application_BeginRequest <\/b>\u2013 \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441. \u041f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437 \u044d\u0442\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u0432\u043e\u0434\u0438\u0442 URL.<\/li>\n<li><b>Application_EndRequest <\/b>\u2013 \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e.<\/li>\n<li><b>Application_PreRequestHandlerExecute<\/b> \u2013 \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u043f\u0440\u0435\u0436\u0434\u0435, \u0447\u0435\u043c ASP.NET \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0438\u043b\u0438 \u0432\u0435\u0431-\u0441\u043b\u0443\u0436\u0431\u0443.<\/li>\n<li><b>Application_PostRequestHandlerExecute<\/b> \u2013 \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 ASP.NET \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443.<\/li>\n<li><b>Applcation_PreSendRequestHeaders <\/b>\u2013 \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a ASP.NET \u043f\u043e\u0441\u044b\u043b\u0430\u0435\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0443 (\u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0443) HTTP \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438.<\/li>\n<li><b>Application_PreSendContent <\/b>\u2013 \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a ASP.NET \u043f\u043e\u0441\u044b\u043b\u0430\u0435\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0443 (\u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0443) HTTP \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435.<\/li>\n<li><b>Application_AcquireRequestState<\/b> \u2013 \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 ASP.NET \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 (\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441\u0435\u0441\u0441\u0438\u0438), \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0435 \u0441 \u0442\u0435\u043a\u0443\u0449\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c.<\/li>\n<li><b>Application_ReleaseRequestState<\/b> \u2013 \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 ASP.NET \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u0441\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442 \u0441\u0432\u043e\u0438 \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f.<\/li>\n<li><b>Application_ResolveRequestCache<\/b> \u2013 \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 ASP.NET \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043c\u043e\u0434\u0443\u043b\u044f\u043c \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0438 \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0442\u044c \u0438\u0437 \u043a\u044d\u0448\u0430, \u043c\u0438\u043d\u0443\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/li>\n<li><b>Application_UpdateRequestCache<\/b> \u2013 \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 ASP.NET \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0434\u0443\u043b\u0438 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0433\u043b\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043e\u0442\u0432\u0435\u0442\u0430\u0445.<\/li>\n<li><b>Application_AuthenticateRequest<\/b> \u2013 \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u043c\u043e\u0434\u0443\u043b\u044c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043b\u0438\u0447\u043d\u043e\u0441\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043a\u0430\u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e. \u0412 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u0443\u0447\u0435\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0443\u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u044b.<\/li>\n<li><b>Application_AuthorizeRequest <\/b>\u2013 \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u043c\u043e\u0434\u0443\u043b\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c.<\/li>\n<li><b>Session_Start<\/b> \u2013 \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u043d\u043e\u0432\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0441\u0430\u0439\u0442.<\/li>\n<li><b>Session_End <\/b>\u2013 \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u0438\u0441\u0442\u0435\u043a\u0430\u0435\u0442 \u0432\u0440\u0435\u043c\u044f \u0441\u0435\u0441\u0441\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0438\u043b\u0438 \u043e\u043d \u043f\u043e\u043a\u0438\u0434\u0430\u0435\u0442 \u0441\u0430\u0439\u0442.<\/li>\n<\/ul>\n<p>   \u0425\u043e\u0440\u043e\u0448\u043e. \u0422\u0435\u043f\u0435\u0440\u044c, \u0447\u0442\u043e\u0431\u044b \u0432\u043e\u043e\u0447\u0438\u044e \u0443\u0431\u0435\u0434\u0438\u043c\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0451 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u0447\u0435\u0440\u0435\u0437 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 NLog \u043c\u043e\u0434\u0443\u043b\u044f \u0432 NuGet.<\/p>\n<h5>Package Manager Console <\/h5>\n<p>  \u0412 NuGet \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434 \u043f\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435\\\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044e\\\u043f\u043e\u0438\u0441\u043a\u0443 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0432\u0435\u0449\u0435\u0439, \u0442\u0438\u043f\u0430 <a href=\"http:\/\/ru.wikipedia.org\/wiki\/%D0%A1%D0%BA%D0%B0%D1%84%D1%84%D0%BE%D0%BB%D0%B4%D0%B8%D0%BD%D0%B3\">\u0441\u043a\u0430\u0444\u0444\u043e\u043b\u0434\u0438\u043d\u0433\u0430<\/a>. <br \/>  \u0414\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0432\u0441\u0435\u0445 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u043f\u0438\u0448\u0435\u043c:  <\/p>\n<pre><code class=\"bash\">Get-Package <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u043a \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u043c\u043e\u0434\u0443\u043b\u0435\u0439:  <\/p>\n<pre><code class=\"bash\">Get-Package \u2013ListAvailable <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c NLog  <\/p>\n<pre><code class=\"bash\">Get-Package -ListAvailable -Filter NLog <\/code><\/pre>\n<p>  \u0418\u043b\u0438   <\/p>\n<pre><code class=\"bash\">Get-Package -ListAvailable  | where {$_.Id -match &quot;NLog&quot;} (\u044d\u0442\u043e \u0434\u043e\u043b\u044c\u0448\u0435) <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043c\u043e\u0434\u0443\u043b\u044f NLog \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 (\u0435\u0441\u043b\u0438 \u0438\u0445 \u0432 \u0441\u043e\u043b\u044e\u0448\u0435\u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0434\u043d\u043e\u0433\u043e) \u0438 \u0432\u0432\u0435\u0441\u0442\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0443:  <\/p>\n<pre><code class=\"bash\">Install-Package NLog <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/536\/155\/fad\/536155fadd87edca1a3a46fcaaec973b.jpg\"\/><\/p>\n<p>  \u0424\u0430\u0439\u043b\u044b \u043a\u043e\u043f\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0435\u043a\u0442, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0441\u0431\u043e\u0440\u043a\u0438 \u0438 web.config \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d.<br \/>  \u0414\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043c\u043e\u0434\u0443\u043b\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043d\u0435 \u0431\u044b\u043b \u0441\u0432\u044f\u0437\u0430\u043d \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438. \u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"bash\">Uninstall-Package NLog <\/code><\/pre>\n<p>  <\/p>\n<h5>NLog<\/h5>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439 \u043d\u0430 NLog (<a href=\"http:\/\/nlog-project.org\/wiki\/Tutorial\">http:\/\/nlog-project.org\/wiki\/Tutorial<\/a>) \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 Web.config:<\/p>\n<pre><code class=\"xml\">&lt;nlog xmlns=&quot;http:\/\/www.nlog-project.org\/schemas\/NLog.xsd&quot; xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot;&gt;     &lt;targets&gt;       &lt;target name=&quot;logfile&quot; xsi:type=&quot;File&quot; fileName=&quot;C:\/\/file.txt&quot; \/&gt;     &lt;\/targets&gt;     &lt;rules&gt;       &lt;logger name=&quot;*&quot; minlevel=&quot;Info&quot; writeTo=&quot;logfile&quot; \/&gt;     &lt;\/rules&gt;   &lt;\/nlog&gt; <\/code><\/pre>\n<p>  \u041c\u044b \u0435\u0435 \u043f\u043e\u0442\u043e\u043c \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043c. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043a\u043e\u0434 (Global.asax.cs):  <\/p>\n<pre><code class=\"cs\">protected void Application_Start()         {             logger.Info(&quot;Application Start&quot;);              AreaRegistration.RegisterAllAreas();              FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);             RouteConfig.RegisterRoutes(RouteTable.Routes);             BundleConfig.RegisterBundles(BundleTable.Bundles);         }          public void Init()         {             logger.Info(&quot;Application Init&quot;);         }          public void Dispose()         {             logger.Info(&quot;Application Dispose&quot;);         }          protected void Application_Error()         {             logger.Info(&quot;Application Error&quot;);         }           protected void Application_End()         {             logger.Info(&quot;Application End&quot;);         } <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 (Stop). \u041e\u0442\u043a\u0440\u043e\u0435\u043c \u0444\u0430\u0439\u043b C:\/\/file.txt. \u041c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u043a\u0430\u043a\u0438\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u043b\u0438. <\/p>\n<pre><code class=\"bash\">2012-09-18 19:18:11.5668|INFO|Lesson1.MvcApplication|Application Start 2012-09-18 19:18:13.7319|INFO|Lesson1.MvcApplication|Application Init 2012-09-18 19:18:14.2709|INFO|Lesson1.MvcApplication|Application Init 2012-09-18 19:18:14.2769|INFO|Lesson1.MvcApplication|Application BeginRequest 2012-09-18 19:18:14.3579|INFO|Lesson1.MvcApplication|Application AuthenticateRequest 2012-09-18 19:18:14.3579|INFO|Lesson1.MvcApplication|Application AuthorizeRequest 2012-09-18 19:18:14.3579|INFO|Lesson1.MvcApplication|Application ResolveRequestCache 2012-09-18 19:18:14.3989|INFO|Lesson1.MvcApplication|Session Start 2012-09-18 19:18:14.3989|INFO|Lesson1.MvcApplication|Application AcquireRequestState 2012-09-18 19:18:14.3989|INFO|Lesson1.MvcApplication|Application PreRequestHandlerExecute 2012-09-18 19:18:15.9580|INFO|Lesson1.MvcApplication|Application PreRequestHandlerExecute 2012-09-18 19:18:15.9580|INFO|Lesson1.MvcApplication|Application ReleaseRequestState 2012-09-18 19:18:15.9580|INFO|Lesson1.MvcApplication|Application UpdateRequestCache 2012-09-18 19:18:15.9580|INFO|Lesson1.MvcApplication|Application EndRequest 2012-09-18 19:18:15.9580|INFO|Lesson1.MvcApplication|Application PreSendRequestHeaders 2012-09-18 19:18:35.6061|INFO|Lesson1.MvcApplication|Session End 2012-09-18 19:18:38.0833|INFO|Lesson1.MvcApplication|Application Dispose 2012-09-18 19:18:38.0833|INFO|Lesson1.MvcApplication|Application End 2012-09-18 19:18:39.1383|INFO|Lesson1.MvcApplication|Application Dispose <\/code><\/pre>\n<p>  \u0412 Application_Start \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f:  <\/p>\n<ul>\n<li>Area (\u043e\u0431\u043b\u0430\u0441\u0442\u0438),<\/li>\n<li>Filter (\u0444\u0438\u043b\u044c\u0442\u0440\u044b),<\/li>\n<li>Bundle (\u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0442\u044b),<\/li>\n<li>Route (\u043c\u0430\u0440\u0448\u0440\u0443\u0442\u044b).<\/li>\n<\/ul>\n<p>  \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043f\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 Filter, \u0412undle \u0438 Route \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043f\u0430\u043f\u043a\u0435 App_Start.<\/p>\n<h5>WebActivator<\/h5>\n<p>  WebActivator \u2013 \u044d\u0442\u043e \u043c\u043e\u0434\u0443\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043a\u043e\u0434 \u0434\u043e \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u0442\u0430\u0440\u0442\u0430 App_Start. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u0411\u0414 \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c.<br \/>  \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c:<\/p>\n<pre><code class=\"bash\">Install-Package WebActivator <\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043b\u0430\u0441\u0441 \u0432 App_Start \u043f\u0430\u043f\u043a\u0443:<\/p>\n<pre><code class=\"cs\">[assembly: WebActivator.PreApplicationStartMethod(typeof(PreStartApp), &quot;Start&quot;)] namespace Lesson1.App_Start {     public static class PreStartApp     {         private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();          \/\/\/ &lt;summary&gt;         \/\/\/ \u041c\u0435\u0442\u043e\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u043f\u0435\u0440\u0435\u0434 \u0441\u0442\u0430\u0440\u0442\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f                 \/\/\/ &lt;\/summary&gt;         public static void Start()         {             logger.Info(&quot;Application PreStart&quot;);         }     } } <\/code><\/pre>\n<p>  \u0412 \u0444\u0430\u0439\u043b\u0435 \u043b\u043e\u0433\u043e\u0432 \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0441\u0442\u0440\u043e\u043a\u0430 Application PreStart \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u043d\u044c\u0448\u0435 Application Start:  <\/p>\n<pre><code class=\"bash\">2012-09-19 10:29:01.3950|INFO|Lesson1.App_Start.PreStartApp|Application PreStart 2012-09-19 10:29:01.6290|INFO|Lesson1.MvcApplication|Application Start <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0447\u0435\u0442\u044b\u0440\u0435 \u0444\u0430\u0439\u043b\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f trace (\u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0438), debug (\u043e\u0442\u043b\u0430\u0434\u043a\u0438), info (\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438), error (\u043e\u0448\u0438\u0431\u043a\u0438). \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043c\u0435\u0441\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u0438: <b> \/Contents\/logs\/[\u0442\u0435\u043a\u0443\u0449\u0430\u044f \u0434\u0430\u0442\u0430]<\/b> \u041f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e:  <\/p>\n<pre><code class=\"xml\">&lt;nlog autoReload=&quot;true&quot; xmlns=&quot;http:\/\/www.nlog-project.org\/schemas\/NLog.xsd&quot; xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot;&gt;     &lt;variable name=&quot;logDirectory&quot; value=&quot;${basedir}\/Content\/logs\/${shortdate}&quot; \/&gt;     &lt;targets&gt;       &lt;target name=&quot;fileLogTrace&quot; xsi:type=&quot;File&quot; fileName=&quot;${logDirectory}\/trace.txt&quot; \/&gt;       &lt;target name=&quot;fileLogDebug&quot; xsi:type=&quot;File&quot; fileName=&quot;${logDirectory}\/debug.txt&quot; \/&gt;       &lt;target name=&quot;fileLogInfo&quot; xsi:type=&quot;File&quot; fileName=&quot;${logDirectory}\/info.txt&quot; \/&gt;       &lt;target name=&quot;fileLogErrors&quot; xsi:type=&quot;File&quot; fileName=&quot;${logDirectory}\/errors.txt&quot; \/&gt;     &lt;\/targets&gt;     &lt;rules&gt;       &lt;logger name=&quot;*&quot; level=&quot;Trace&quot; writeTo=&quot;fileLogTrace&quot; \/&gt;       &lt;logger name=&quot;*&quot; level=&quot;Debug&quot; writeTo=&quot;fileLogDebug&quot; \/&gt;       &lt;logger name=&quot;*&quot; level=&quot;Info&quot; writeTo=&quot;fileLogInfo&quot; \/&gt;       &lt;logger name=&quot;*&quot; minlevel=&quot;Warn&quot; writeTo=&quot;fileLogErrors&quot; \/&gt;     &lt;\/rules&gt;   &lt;\/nlog&gt; <\/code><\/pre>\n<h5>Log2Console<\/h5>\n<p>  \u0414\u043b\u044f NLog \u0435\u0441\u0442\u044c \u0435\u0449\u0435 \u043a\u043b\u0430\u0441\u0441\u043d\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 Log2Console, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043b\u043e\u0433\u0438 \u043f\u0440\u044f\u043c\u043e \u0432 \u043e\u043a\u043d\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. <\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/b04\/796\/970\/b047969706fd6b3be30054ac4726ed8f.jpg\"\/><\/p>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0438 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043f\u0440\u0438\u0435\u043c\u0449\u0438\u043a:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/8da\/d50\/227\/8dad50227849223d5358552484bc63e5.jpg\"\/><\/p>\n<p>  \u0412 Web.config \u043f\u0438\u0448\u0435\u043c:<\/p>\n<pre><code class=\"xml\">&lt;target name=&quot;TcpOutlet&quot; xsi:type=&quot;NLogViewer&quot; address=&quot;tcp4:\/\/localhost:4505&quot;\/&gt; <\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0449\u0430\u044e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430\u0434\u043e <b>address=\u201dtcp4:\/\/\u2026\u201d<\/b>, \u0430 \u043d\u0435 <b>address=\u201dtcp:\/\/\u2026\u201d<\/b><\/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\/176001\/\"> http:\/\/habrahabr.ru\/post\/176001\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t<b>\u0426\u0435\u043b\u044c \u0443\u0440\u043e\u043a\u0430:<\/b> \u0418\u0437\u0443\u0447\u0438\u0442\u044c Global.asax \u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0435\u0431-\u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0418\u0437\u0443\u0447\u0435\u043d\u0438\u0435 Nuget \u0438 \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<h5>\u041d\u0430\u0447\u0430\u043b\u043e<\/h5>\n<p>   \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 ASP.NET MVC 4 Web Application \u00abLesson1\u00bb (\u0440\u0438\u0441 1.):<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/ab8\/247\/78f\/ab824778ffc23afca87e93b7295e7ffe.jpg\"\/><\/p>\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-176001","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/176001","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=176001"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/176001\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=176001"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=176001"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=176001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}