{"id":343586,"date":"2023-01-06T15:06:08","date_gmt":"2023-01-06T15:06:08","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=343586"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=343586","title":{"rendered":"<span>\u0428\u0430\u0431\u043b\u043e\u043d \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Asp .Net Core 6 Web API \u0441 \u043f\u0440\u0435\u0434\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u043e\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041e\u0431\u044b\u0447\u043d\u043e \u043c\u043e\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 REST \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432. \u0427\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u044d\u0442\u0430 \u0432\u0435\u0434\u0435\u0442\u0441\u044f \u043d\u0430 \u0431\u0430\u0437\u0435 \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0440\u0430\u043d\u0435\u0435 \u043f\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0443 Web API \u0432 VisualStudio. \u0421\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0435 \u0447\u0430\u0441\u0442\u043e, \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0435 \u043c\u043d\u043e\u0439, \u0431\u044b\u043b\u043e \u0435\u0449\u0435 \u043d\u0430 .NET Core 3.1, \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u043a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u043e\u0434\u043e\u0431\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430, \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0435 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u043b\u043e \u0432\u0441\u0435\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u044e. \u0421\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u043d\u0430\u043a\u0430\u043d\u0443\u043d\u0435, \u0440\u0435\u0448\u0438\u043b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (<a href=\"https:\/\/github.com\/SergeyKashkovsky\/WebApiTemplate\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 GitHub<\/a>), \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443\u0436\u0435 \u0432\u0441\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u0438 \u0433\u043e\u0442\u043e\u0432\u043e. \u041a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043f\u0440\u0438\u0432\u043e\u0436\u0443 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u041f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u0440\u0430\u0437\u0431\u0438\u0442\u044c \u0441\u0430\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u0431\u043b\u043e\u043a\u0438, \u0447\u0442\u043e\u0431\u044b \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445 \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435. \u041d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u0441\u0432\u044f\u0449\u0430\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043d\u0435 \u0432\u0434\u0430\u0432\u0430\u044f\u0441\u044c \u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0442\u043e\u0439 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 &#8212; \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u0432\u043e\u0436\u0443 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443\u0447\u0438\u043b\u0441\u044f \u0441\u0430\u043c. \u0421\u0442\u0430\u0442\u044c\u044f \u043c\u043e\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0434\u043b\u044f \u043d\u043e\u0432\u0438\u0447\u043a\u043e\u0432 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0434\u043b\u044f \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u0435\u0445 \u0438\u043b\u0438 \u0438\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 .Net Core 6, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0434\u043b\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a\u0430\u043a \u0438 \u044f, \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0435\u043d\u044b \u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0435\u0433\u043e \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438.<\/p>\n<h3>\u0424\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c<\/h3>\n<ul>\n<li>\n<p>\u0416\u0443\u0440\u043d\u0430\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0444\u0430\u0439\u043b \u0441 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0435\u0439 \u043b\u043e\u0433\u0430<\/p>\n<\/li>\n<li>\n<p>\u0425\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 CORS \u043f\u043e\u043b\u0438\u0442\u0438\u043a \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a API \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u043a\u0440\u043e\u0441\u0441-\u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Kestrel \u043d\u0430 \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u043d\u0438\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u0442\u0430 TCP \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u0435\u043b\u0444-\u0445\u043e\u0441\u0442\u0438\u043d\u0433<\/p>\n<\/li>\n<li>\n<p>\u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0436\u0431\u044b Windows<\/p>\n<\/li>\n<\/ul>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0431\u043e\u0440\u043a\u0438<\/h3>\n<p>\u0421\u0431\u043e\u0440\u043a\u0430, \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 <a href=\"https:\/\/metanit.com\/sharp\/mvc5\/23.1.php\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439,<\/a> \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u044f \u0434\u0432\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u0441\u043b\u043e\u044f &#8212; \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0430\u043c Web API \u0441 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u043c\u0438 \u0438 \u0432\u0441\u0435\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438. \u042d\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 VisualStudio \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0443 &#171;Asp .Net Core Web API&#187; \u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 \u043e\u043f\u0446\u0438\u0439 &#171;Use controllers&#187; \u0438 &#171;Enable Open API support&#187;. <span class=\"habrahidden\">\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u0430\u0432\u0442\u043e\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u043d\u0430 swagger &#8212; \u043d\u0435\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u0448\u0442\u0443\u043a\u0430 \u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438<\/span><\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0443\u0440\u043e\u0432\u043d\u044f \u044f\u0434\u0440\u0430 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0443\u044e \u043f\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0443 &#171;Class Library&#187;<\/p>\n<\/li>\n<\/ul>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b Kestrel \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u043d\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u0442\u0430 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 aspnetcore 6<\/h3>\n<h4>\u0412 \u0444\u0430\u0439\u043b\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 appsettings.json <\/h4>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f TCP \u043f\u043e\u0440\u0442\u0430 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u043c\u0443 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u0443 Kestrel \u043f\u0440\u0438 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 Urls:<\/p>\n<pre><code class=\"json\">...   \"Urls\": \"http:\/\/*:5005\" ...<\/code><\/pre>\n<h4>\u0412 \u0444\u0430\u0439\u043b\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Properties\\launchSettings.json<\/h4>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 Swagger \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u043e\u0442\u043b\u0430\u0434\u043a\u0438. \u0418\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u043e\u0440\u0442 \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435 <code>applicationUrl<\/code> \u043f\u0440\u043e\u0444\u0438\u043b\u044f \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0441\u0435\u043b\u0444-\u0445\u043e\u0441\u0442:<\/p>\n<pre><code class=\"json\">... \"profiles\": {     \"WebApiTemplate\": {       \"commandName\": \"Project\",       \"dotnetRunMessages\": true,       \"launchBrowser\": true,       \"launchUrl\": \"swagger\",       \"applicationUrl\": \"http:\/\/localhost:5005\",       \"environmentVariables\": {         \"ASPNETCORE_ENVIRONMENT\": \"Development\"       }     }, ... <\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u0438\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u0438 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e swagger \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 5005 \u0438 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043c\u0435\u0442\u043e\u0434 Get \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 WeatherForecast \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430 5005 \u043f\u043e\u0440\u0442\u0443:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/74e\/e77\/df3\/74ee77df315bfb27eb40a6bac0dbffb7.png\" width=\"1554\" height=\"700\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/74e\/e77\/df3\/74ee77df315bfb27eb40a6bac0dbffb7.png\"\/><figcaption><\/figcaption><\/figure>\n<h3>\u0412\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 aspnetcore 6<\/h3>\n<p>\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/metanit.com\/sharp\/aspnet6\/4.1.php\" rel=\"noopener noreferrer nofollow\">\u0421\u0442\u0430\u0442\u044c\u044f \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 Metanit<\/a><span class=\"habrahidden\">, \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0440\u0435\u0431\u044f\u0442\u0430\u043c \u0437\u0430 \u0442\u043e\u043b\u043a\u043e\u0432\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/span><\/p>\n<\/li>\n<\/ul>\n<ol>\n<li>\n<p>\u0412 Program.cs \u0432\u043d\u043e\u0441\u0438\u043c \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0441\u043b\u0443\u0436\u0431 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0439 \u0442\u0438\u043f. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0444\u0430\u0439\u043b\u0430 \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c <code>builder<\/code> \u0438 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0441\u0431\u043e\u0440\u043a\u0438 Web \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f <code>var app = builder.Build();<\/code>:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cs\">builder.Services.AddTransient&lt;WebApiService>();<\/code><\/pre>\n<p>\u0420\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u044b\u0445 \u0446\u0438\u043a\u043b\u043e\u0432 \u0432\u043d\u0435\u0434\u0440\u044f\u0435\u043c\u044b\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432 <a href=\"https:\/\/metanit.com\/sharp\/aspnet6\/4.4.php\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>, \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0443, \u043d\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u0443\u044e, \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e. \u0415\u0441\u043b\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c singleton, \u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"cs\">builder.Services.AddSingleton&lt;ISomeClass, SomeClass>();<\/code><\/pre>\n<p>\u043d\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u043d\u0435\u0437\u0430\u043c\u0435\u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430, \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u043f\u0435\u0440\u0432\u043e\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u043d\u0430 \u044d\u0442\u043e\u0442. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0441\u044f \u043d\u0435\u0437\u0430\u043c\u0435\u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cs\">builder.Services.AddSingleton&lt;ISomeClass>(new SomeClass());<\/code><\/pre>\n<p>\u041d\u043e \u0442\u0443\u0442 \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0438, \u0435\u0441\u043b\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u043c\u0435\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438 \u0442\u043e\u0436\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439. \u0412\u0441\u0435 \u044d\u0442\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0437 <code>builder<\/code>.<\/p>\n<h3>\u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a appsettings.json \u0447\u0435\u0440\u0435\u0437 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 aspnetcore 6<\/h3>\n<p>\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/metanit.com\/sharp\/aspnet6\/6.8.php\" rel=\"noopener noreferrer nofollow\">\u0421\u0442\u0430\u0442\u044c\u044f \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 Metanit<\/a><span class=\"habrahidden\">, \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0440\u0435\u0431\u044f\u0442\u0430\u043c \u0437\u0430 \u0442\u043e\u043b\u043a\u043e\u0432\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/span><\/p>\n<\/li>\n<\/ul>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a (<code>ApplicationSettings<\/code>)<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432 Program.cs. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0444\u0430\u0439\u043b\u0430 \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c <code>builder<\/code> \u0438 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0441\u0431\u043e\u0440\u043a\u0438 Web \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f <code>var app = builder.Build();<\/code>:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cs\">builder.Services.Configure&lt;ApplicationSettings>(builder.Configuration);<\/code><\/pre>\n<ol start=\"3\">\n<li>\n<p>\u0412 \u043a\u043b\u0430\u0441\u0441\u0435, \u0433\u0434\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439:<\/p>\n<\/li>\n<\/ol>\n<ul>\n<li>\n<p>\u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 NuGet, \u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0430\u043a\u0435\u0442 <code>Microsoft.Extensions.Options<\/code><\/p>\n<\/li>\n<li>\n<p>\u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c <code>readonly<\/code> \u043f\u043e\u043b\u0435:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cs\">private readonly ApplicationSettings _settings;<\/code><\/pre>\n<ul>\n<li>\n<p>\u0432\u043d\u0435\u0434\u0440\u044f\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cs\">public WebApiService(IOptions&lt;ApplicationSettings> options) {     _settings = options.Value ?? throw new ArgumentNullException(\"ApplicationSettings\"); }<\/code><\/pre>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 NLog \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 aspnetcore 6<\/h3>\n<p>\u0412 \u043d\u0430\u0448\u0435\u0439 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0442\u0430\u043a \u0437\u0430\u0432\u0435\u0434\u0435\u043d\u043e, \u0447\u0442\u043e \u0432\u0441\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0436\u0443\u0440\u043d\u0430\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u0430\u043a\u0435\u0442\u0430 <a href=\"https:\/\/www.nuget.org\/packages\/NLog\/\" rel=\"noopener noreferrer nofollow\">NLog<\/a>. \u042d\u0442\u0430 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u044f \u0436\u0438\u0432\u0435\u0442 \u0443 \u043d\u0430\u0441 \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d .Net Framework, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0436\u0443\u0440\u043d\u0430\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f .NET Core \u0443\u0436\u0435 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u0432\u0441\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 NLog, \u043d\u043e \u043c\u043d\u0435 \u044d\u0442\u043e \u043d\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431.<\/p>\n<p>\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/NLog\/NLog\/wiki\/Getting-started-with-ASP.NET-Core-6\" rel=\"noopener noreferrer nofollow\">\u0411\u044b\u0441\u0442\u0440\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/NLog\/NLog\/wiki\/Configuration-file\" rel=\"noopener noreferrer nofollow\">\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f<\/a><\/p>\n<\/li>\n<\/ul>\n<ol>\n<li>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c NLog \u0432 Program.cs. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0444\u0430\u0439\u043b\u0430 \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c <code>builder<\/code> \u0438 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0441\u0431\u043e\u0440\u043a\u0438 Web \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f <code>var app = builder.Build();<\/code>:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cs\">\/\/ NLog: Setup NLog for Dependency injection     builder.Logging.ClearProviders();     builder.Host.UseNLog();<\/code><\/pre>\n<ol start=\"2\">\n<li>\n<p>\u0412 \u043a\u043b\u0430\u0441\u0441\u0435, \u0433\u0434\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0436\u0443\u0440\u043d\u0430\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b, \u0432\u043d\u0435\u0434\u0440\u044f\u0435\u043c \u043b\u043e\u0433\u0433\u0435\u0440, \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c, \u043d\u0430\u0437\u043d\u0430\u0447\u0438\u0432 \u0435\u043c\u0443 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044e:<\/p>\n<\/li>\n<\/ol>\n<ul>\n<li>\n<p>\u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 NuGet, \u0435\u0441\u043b\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f, \u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0430\u043a\u0435\u0442 <code>Microsoft.Extensions.Logging.Abstractions<\/code><\/p>\n<\/li>\n<li>\n<p>\u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c <code>readonly<\/code> \u043f\u043e\u043b\u0435:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cs\">private readonly ILogger&lt;WebApiService> _logger; \/\/\u0437\u0434\u0435\u0441\u044c \"WebApiService\" - \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f \u0436\u0443\u0440\u043d\u0430\u043b\u0430, \u0442\u0438\u043f, \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f<\/code><\/pre>\n<ul>\n<li>\n<p>\u0432\u043d\u0435\u0434\u0440\u044f\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cs\">public WebApiService(ILogger&lt;WebApiService> logger) {     _logger = logger; }<\/code><\/pre>\n<ol start=\"3\">\n<li>\n<p>\u0417\u0430\u043f\u0438\u0441\u044c \u0432 \u0436\u0443\u0440\u043d\u0430\u043b:<\/p>\n<pre><code class=\"cs\">_logger.LogDebug($\"{logText}, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0438\u0437 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a: {_settings.SomeParameter}\");<\/code><\/pre>\n<\/li>\n<\/ol>\n<ol start=\"4\">\n<li>\n<p>\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u0446\u0435\u043b\u0438 \u0434\u043b\u044f \u0436\u0443\u0440\u043d\u0430\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438, \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044e \u043b\u043e\u0433 \u0444\u0430\u0439\u043b\u043e\u0432, \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 nlog.config. \u0420\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u043d\u044b\u0439 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 <a href=\"https:\/\/github.com\/SergeyKashkovsky\/WebApiTemplate\/blob\/main\/WebApiTemplate\/nlog.config\" rel=\"noopener noreferrer nofollow\">\u0444\u0430\u0439\u043b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438<\/a> \u0443\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u043b\u043e\u0433-\u0444\u0430\u0439\u043b\u044b \u0437\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 10 \u0434\u043d\u0435\u0439. \u0417\u0430\u043f\u0438\u0441\u044c \u043b\u043e\u0433\u0430 \u0432 \u0444\u0430\u0439\u043b \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u0431\u0438\u0432\u0430\u043b\u043e \u0436\u0443\u0440\u043d\u0430\u043b \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a Microsoft.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <a href=\"http:\/\/localhost:5005\/WeatherForecast\" rel=\"noopener noreferrer nofollow\">http:\/\/localhost:5005\/WeatherForecast<\/a>. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u0437 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0448\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \u0436\u0443\u0440\u043d\u0430\u043b\u0430:<\/p>\n<\/li>\n<\/ol>\n<pre><code>2023-01-06 13:10:45.2375 | INFO | Microsoft.AspNetCore.Hosting.Diagnostics | Request starting HTTP\/1.1 GET http:\/\/localhost:5005\/WeatherForecast - - |  2023-01-06 13:10:45.3266 | DEBUG | WebApiTemplate.Controllers.WeatherForecastController | \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0438\u0437 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a: Some value |  2023-01-06 13:10:45.3266 | DEBUG | WebApiTemplate.Core.Services.WebApiService | \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0443\u0440\u043e\u0432\u043d\u044f \u044f\u0434\u0440\u0430, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0438\u0437 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a: Some value |  2023-01-06 13:10:45.3266 | INFO | WebApiTemplate.Controllers.WeatherForecastController | Action status: Ok |  2023-01-06 13:10:45.3945 | INFO | Microsoft.AspNetCore.Hosting.Diagnostics | Request finished HTTP\/1.1 GET http:\/\/localhost:5005\/WeatherForecast - - - 200 - application\/json;+charset=utf-8 157.2347ms |<\/code><\/pre>\n<p>\u0412 \u0436\u0443\u0440\u043d\u0430\u043b\u0435 \u0432\u0438\u0434\u043d\u043e \u043f\u043e\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440, \u043d\u0430\u0447\u0430\u043b\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430 <code>WebApiTemplate.Controllers.WeatherForecastController.Get<\/code>, \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 <code>WebApiTemplate.Core.Services.WebApiService.SomeAction<\/code>, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0438 \u043e\u0442\u0447\u0435\u0442 \u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 CORS \u043f\u043e\u043b\u0438\u0442\u0438\u043a \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 aspnetcore 6<\/h3>\n<p>\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/metanit.com\/sharp\/aspnet6\/14.2.php\" rel=\"noopener noreferrer nofollow\">\u0421\u0442\u0430\u0442\u044c\u044f \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 Metanit \u043f\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 CORS<\/a><span class=\"habrahidden\">, \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0440\u0435\u0431\u044f\u0442\u0430\u043c \u0437\u0430 \u0442\u043e\u043b\u043a\u043e\u0432\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/span><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/metanit.com\/sharp\/aspnet6\/14.2.php\" rel=\"noopener noreferrer nofollow\">\u0421\u0442\u0430\u0442\u044c\u044f \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 Metanit \u043f\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u043f\u043e\u043b\u0438\u0442\u0438\u043a CORS<\/a><span class=\"habrahidden\">, \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0440\u0435\u0431\u044f\u0442\u0430\u043c \u0437\u0430 \u0442\u043e\u043b\u043a\u043e\u0432\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/span><\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u043c\u043e\u0438\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u043d\u0443\u0436\u0434 \u043e\u0431\u044b\u0447\u043d\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u0432\u0430 \u043d\u0430\u0431\u043e\u0440\u0430 \u043f\u043e\u043b\u0438\u0442\u0438\u043a: \u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438 (\u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043e \u0432\u0441\u0435) \u0438 \u0434\u043b\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 (\u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f)<\/p>\n<ol>\n<li>\n<p>\u0412 appsettings.json \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>AllowedOrigins<\/code>:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"json\">{   ...   \"AllowedOrigins\": [     \"http:\/\/localhost:8080\"   ] }<\/code><\/pre>\n<ol start=\"2\">\n<li>\n<p>\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cs\">\/\/\/ &lt;summary> \/\/\/ \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \/\/\/ &lt;\/summary> public class ApplicationSettings {     ...     \/\/\/ &lt;summary>     \/\/\/ \u0420\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043d\u044b\u0435 \u0434\u043e\u043c\u0435\u043d\u044b - \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0434\u043b\u044f \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438 CORS     \/\/\/ &lt;\/summary>     public string[] AllowedOrigins { get; set; } } <\/code><\/pre>\n<ol start=\"3\">\n<li>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a, \u0432 Program.cs \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0444\u0430\u0439\u043b\u0430 \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c <code>builder<\/code> \u0438 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0441\u0431\u043e\u0440\u043a\u0438 Web \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f <code>var app = builder.Build();<\/code>:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cs\">var settings = builder.Configuration.Get&lt;ApplicationSettings>() ?? throw new ArgumentNullException(\"ApplicationSettings\", \"\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0430\");<\/code><\/pre>\n<ol start=\"4\">\n<li>\n<p>\u0412 Program.cs \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c CORS \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438 \u0434\u043e \u0432\u044b\u0437\u043e\u0432\u0430 <code>builder.Build()<\/code><\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cs\">    builder.Services.AddCors(options => options.AddPolicy(\"AllowAny\", builder => builder         .AllowAnyOrigin()         .AllowAnyHeader()         .AllowAnyMethod())     );      builder.Services.AddCors(options => options.AddPolicy(\"AllowSome\", builder => builder         .WithOrigins(settings.AllowedOrigins)         .AllowAnyHeader()         .AllowAnyMethod()         .AllowCredentials())     );<\/code><\/pre>\n<ol start=\"5\">\n<li>\n<p>\u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0438\u043f\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (Debug \u0438\u043b\u0438 Release), \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0442\u0443 \u0438\u043b\u0438 \u0438\u043d\u0443\u044e \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0443 \u0432 \u0444\u0430\u0439\u043b\u0435 Program.cs \u043c\u0435\u0436\u0434\u0443 <code>var app = builder.Build();<\/code> \u0438 <code>app.Run();<\/code>:<\/p>\n<\/li>\n<\/ol>\n<pre><code>#if DEBUG     app.UseCors(\"AllowAny\"); #else     app.UseCors(\"AllowSpecURLs\"); #endif<\/code><\/pre>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f aspnetcore 6 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0436\u0431\u044b Windows<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u0430\u043a \u0441\u043b\u0443\u0436\u0431\u0443, \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u0441\u043b\u0443\u0436\u0431 WIndows, \u043e\u0436\u0438\u0434\u0430\u044f \u0441\u0442\u0430\u0442\u0443\u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0438\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 stdout, \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0432 \u044d\u0442\u043e\u0442 \u0441\u0442\u0430\u0442\u0443\u0441, \u0432\u044b\u0434\u0430\u0441\u0442 \u043e\u0448\u0438\u0431\u043a\u0443 &#171;\u041e\u0448\u0438\u0431\u043a\u0430 1053 \u0421\u043b\u0443\u0436\u0431\u0430 \u043d\u0435 \u043e\u0442\u0432\u0435\u0442\u0438\u043b\u0430 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441 \u0441\u0432\u043e\u0435\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e&#187;. \u0414\u043b\u044f \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/learn.microsoft.com\/ru-ru\/aspnet\/core\/host-and-deploy\/windows-service?view=aspnetcore-6.0&amp;tabs=visual-studio\" rel=\"noopener noreferrer nofollow\">\u0421\u0442\u0430\u0442\u044c\u044f MSDN \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c<\/a><\/p>\n<\/li>\n<\/ul>\n<ol>\n<li>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043f\u0430\u043a\u0435\u0442 Microsoft.Extensions.Hosting.WindowsServices<\/p>\n<\/li>\n<li>\n<p>\u0432 Program.cs \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 <code>builder<\/code> \u0432\u0437\u0430\u043c\u0435\u043d \u0441\u0442\u0440\u043e\u043a\u0438 <code>var builder = WebApplication.CreateBuilder(args);<\/code><\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cs\">var options = new WebApplicationOptions {     Args = args,     ContentRootPath = WindowsServiceHelpers.IsWindowsService()         ? AppContext.BaseDirectory : default }; var builder = WebApplication.CreateBuilder(options);<\/code><\/pre>\n<ol start=\"3\">\n<li>\n<p>\u041f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0435\u043c \u0435\u0433\u043e \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 Windows \u043b\u044e\u0431\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u043b\u044e\u0431\u044b\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441\u043b\u0443\u0436\u0431\u0443<\/p>\n<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/709250\/\"> https:\/\/habr.com\/ru\/post\/709250\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041e\u0431\u044b\u0447\u043d\u043e \u043c\u043e\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 REST \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432. \u0427\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u044d\u0442\u0430 \u0432\u0435\u0434\u0435\u0442\u0441\u044f \u043d\u0430 \u0431\u0430\u0437\u0435 \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0440\u0430\u043d\u0435\u0435 \u043f\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0443 Web API \u0432 VisualStudio. \u0421\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0435 \u0447\u0430\u0441\u0442\u043e, \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0435 \u043c\u043d\u043e\u0439, \u0431\u044b\u043b\u043e \u0435\u0449\u0435 \u043d\u0430 .NET Core 3.1, \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u043a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u043e\u0434\u043e\u0431\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430, \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0435 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u043b\u043e \u0432\u0441\u0435\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u044e. \u0421\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u043d\u0430\u043a\u0430\u043d\u0443\u043d\u0435, \u0440\u0435\u0448\u0438\u043b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (<a href=\"https:\/\/github.com\/SergeyKashkovsky\/WebApiTemplate\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 GitHub<\/a>), \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443\u0436\u0435 \u0432\u0441\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u0438 \u0433\u043e\u0442\u043e\u0432\u043e. \u041a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043f\u0440\u0438\u0432\u043e\u0436\u0443 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u041f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u0440\u0430\u0437\u0431\u0438\u0442\u044c \u0441\u0430\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u0431\u043b\u043e\u043a\u0438, \u0447\u0442\u043e\u0431\u044b \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445 \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435. \u041d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u0441\u0432\u044f\u0449\u0430\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043d\u0435 \u0432\u0434\u0430\u0432\u0430\u044f\u0441\u044c \u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0442\u043e\u0439 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 &#8212; \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u0432\u043e\u0436\u0443 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443\u0447\u0438\u043b\u0441\u044f \u0441\u0430\u043c. \u0421\u0442\u0430\u0442\u044c\u044f \u043c\u043e\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0434\u043b\u044f \u043d\u043e\u0432\u0438\u0447\u043a\u043e\u0432 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0434\u043b\u044f \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u0435\u0445 \u0438\u043b\u0438 \u0438\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 .Net Core 6, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0434\u043b\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a\u0430\u043a \u0438 \u044f, \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0435\u043d\u044b \u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0435\u0433\u043e \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438.<\/p>\n<h3>\u0424\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c<\/h3>\n<ul>\n<li>\n<p>\u0416\u0443\u0440\u043d\u0430\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0444\u0430\u0439\u043b \u0441 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0435\u0439 \u043b\u043e\u0433\u0430<\/p>\n<\/li>\n<li>\n<p>\u0425\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 CORS \u043f\u043e\u043b\u0438\u0442\u0438\u043a \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a API \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u043a\u0440\u043e\u0441\u0441-\u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Kestrel \u043d\u0430 \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u043d\u0438\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u0442\u0430 TCP \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u0435\u043b\u0444-\u0445\u043e\u0441\u0442\u0438\u043d\u0433<\/p>\n<\/li>\n<li>\n<p>\u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0436\u0431\u044b Windows<\/p>\n<\/li>\n<\/ul>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0431\u043e\u0440\u043a\u0438<\/h3>\n<p>\u0421\u0431\u043e\u0440\u043a\u0430, \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 <a href=\"https:\/\/metanit.com\/sharp\/mvc5\/23.1.php\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439,<\/a> \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u044f \u0434\u0432\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u0441\u043b\u043e\u044f &#8212; \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0430\u043c Web API \u0441 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u043c\u0438 \u0438 \u0432\u0441\u0435\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438. \u042d\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 VisualStudio \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0443 &#171;Asp .Net Core Web API&#187; \u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 \u043e\u043f\u0446\u0438\u0439 &#171;Use controllers&#187; \u0438 &#171;Enable Open API support&#187;. <span class=\"habrahidden\">\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u0430\u0432\u0442\u043e\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u043d\u0430 swagger &#8212; \u043d\u0435\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u0448\u0442\u0443\u043a\u0430 \u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438<\/span><\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0443\u0440\u043e\u0432\u043d\u044f \u044f\u0434\u0440\u0430 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0443\u044e \u043f\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0443 &#171;Class Library&#187;<\/p>\n<\/li>\n<\/ul>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b Kestrel \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u043d\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u0442\u0430 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 aspnetcore 6<\/h3>\n<h4>\u0412 \u0444\u0430\u0439\u043b\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 appsettings.json <\/h4>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f TCP \u043f\u043e\u0440\u0442\u0430 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u043c\u0443 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u0443 Kestrel \u043f\u0440\u0438 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 Urls:<\/p>\n<pre><code class=\"json\">...   \"Urls\": \"http:\/\/*:5005\" ...<\/code><\/pre>\n<h4>\u0412 \u0444\u0430\u0439\u043b\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Properties\\launchSettings.json<\/h4>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 Swagger \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u043e\u0442\u043b\u0430\u0434\u043a\u0438. \u0418\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u043e\u0440\u0442 \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435 <code>applicationUrl<\/code> \u043f\u0440\u043e\u0444\u0438\u043b\u044f \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0441\u0435\u043b\u0444-\u0445\u043e\u0441\u0442:<\/p>\n<pre><code class=\"json\">... \"profiles\": {     \"WebApiTemplate\": {       \"commandName\": \"Project\",       \"dotnetRunMessages\": true,       \"launchBrowser\": true,       \"launchUrl\": \"swagger\",       \"applicationUrl\": \"http:\/\/localhost:5005\",       \"environmentVariables\": {         \"ASPNETCORE_ENVIRONMENT\": \"Development\"       }     }, ... <\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u0438\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u0438 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e swagger \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 5005 \u0438 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043c\u0435\u0442\u043e\u0434 Get \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 WeatherForecast \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430 5005 \u043f\u043e\u0440\u0442\u0443:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h3>\u0412\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 aspnetcore 6<\/h3>\n<p>\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/metanit.com\/sharp\/aspnet6\/4.1.php\" rel=\"noopener noreferrer nofollow\">\u0421\u0442\u0430\u0442\u044c\u044f \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 Metanit<\/a><span class=\"habrahidden\">, \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0440\u0435\u0431\u044f\u0442\u0430\u043c \u0437\u0430 \u0442\u043e\u043b\u043a\u043e\u0432\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/span><\/p>\n<\/li>\n<\/ul>\n<ol>\n<li>\n<p>\u0412 Program.cs \u0432\u043d\u043e\u0441\u0438\u043c \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0441\u043b\u0443\u0436\u0431 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0439 \u0442\u0438\u043f. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0444\u0430\u0439\u043b\u0430 \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c <code>builder<\/code> \u0438 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0441\u0431\u043e\u0440\u043a\u0438 Web \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f <code>var app = builder.Build();<\/code>:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cs\">builder.Services.AddTransient&lt;WebApiService>();<\/code><\/pre>\n<p>\u0420\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u044b\u0445 \u0446\u0438\u043a\u043b\u043e\u0432 \u0432\u043d\u0435\u0434\u0440\u044f\u0435\u043c\u044b\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432 <a href=\"https:\/\/metanit.com\/sharp\/aspnet6\/4.4.php\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>, \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0443, \u043d\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u0443\u044e, \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e. \u0415\u0441\u043b\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c singleton, \u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"cs\">builder.Services.AddSingleton&lt;ISomeClass, SomeClass>();<\/code><\/pre>\n<p>\u043d\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u043d\u0435\u0437\u0430\u043c\u0435\u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430, \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u043f\u0435\u0440\u0432\u043e\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u043d\u0430 \u044d\u0442\u043e\u0442. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0441\u044f \u043d\u0435\u0437\u0430\u043c\u0435\u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cs\">builder.Services.AddSingleton&lt;ISomeClass>(new SomeClass());<\/code><\/pre>\n<p>\u041d\u043e \u0442\u0443\u0442 \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0438, \u0435\u0441\u043b\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u043c\u0435\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438 \u0442\u043e\u0436\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439. \u0412\u0441\u0435 \u044d\u0442\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0437 <code>builder<\/code>.<\/p>\n<h3>\u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a appsettings.json \u0447\u0435\u0440\u0435\u0437 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 aspnetcore 6<\/h3>\n<p>\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/metanit.com\/sharp\/aspnet6\/6.8.php\" rel=\"noopener noreferrer nofollow\">\u0421\u0442\u0430\u0442\u044c\u044f \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 Metanit<\/a><span class=\"habrahidden\">, \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0440\u0435\u0431\u044f\u0442\u0430\u043c \u0437\u0430 \u0442\u043e\u043b\u043a\u043e\u0432\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/span><\/p>\n<\/li>\n<\/ul>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a (<code>ApplicationSettings<\/code>)<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432 Program.cs. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0444\u0430\u0439\u043b\u0430 \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c <code>builder<\/code> \u0438 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0441\u0431\u043e\u0440\u043a\u0438 Web \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f <code>var app = builder.Build();<\/code>:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cs\">builder.Services.Configure&lt;ApplicationSettings>(builder.Configuration);<\/code><\/pre>\n<ol start=\"3\">\n<li>\n<p>\u0412 \u043a\u043b\u0430\u0441\u0441\u0435, \u0433\u0434\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439:<\/p>\n<\/li>\n<\/ol>\n<ul>\n<li>\n<p>\u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 NuGet, \u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0430\u043a\u0435\u0442 <code>Microsoft.Extensions.Options<\/code><\/p>\n<\/li>\n<li>\n<p>\u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c <code>readonly<\/code> \u043f\u043e\u043b\u0435:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cs\">private readonly ApplicationSettings _settings;<\/code><\/pre>\n<ul>\n<li>\n<p>\u0432\u043d\u0435\u0434\u0440\u044f\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cs\">public WebApiService(IOptions&lt;ApplicationSettings> options) {     _settings = options.Value ?? throw new ArgumentNullException(\"ApplicationSettings\"); }<\/code><\/pre>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 NLog \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 aspnetcore 6<\/h3>\n<p>\u0412 \u043d\u0430\u0448\u0435\u0439 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0442\u0430\u043a \u0437\u0430\u0432\u0435\u0434\u0435\u043d\u043e, \u0447\u0442\u043e \u0432\u0441\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0436\u0443\u0440\u043d\u0430\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u0430\u043a\u0435\u0442\u0430 <a href=\"https:\/\/www.nuget.org\/packages\/NLog\/\" rel=\"noopener noreferrer nofollow\">NLog<\/a>. \u042d\u0442\u0430 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u044f \u0436\u0438\u0432\u0435\u0442 \u0443 \u043d\u0430\u0441 \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d .Net Framework, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0436\u0443\u0440\u043d\u0430\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f .NET Core \u0443\u0436\u0435 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u0432\u0441\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 NLog, \u043d\u043e \u043c\u043d\u0435 \u044d\u0442\u043e \u043d\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431.<\/p>\n<p>\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/NLog\/NLog\/wiki\/Getting-started-with-ASP.NET-Core-6\" rel=\"noopener noreferrer nofollow\">\u0411\u044b\u0441\u0442\u0440\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/NLog\/NLog\/wiki\/Configuration-file\" rel=\"noopener noreferrer nofollow\">\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f<\/a><\/p>\n<\/li>\n<\/ul>\n<ol>\n<li>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c NLog \u0432 Program.cs. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0444\u0430\u0439\u043b\u0430 \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c <code>builder<\/code> \u0438 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0441\u0431\u043e\u0440\u043a\u0438 Web \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f <code>var app = builder.Build();<\/code>:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cs\">\/\/ NLog: Setup NLog for Dependency injection     builder.Logging.ClearProviders();     builder.Host.UseNLog();<\/code><\/pre>\n<ol start=\"2\">\n<li>\n<p>\u0412 \u043a\u043b\u0430\u0441\u0441\u0435, \u0433\u0434\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0436\u0443\u0440\u043d\u0430\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b, \u0432\u043d\u0435\u0434\u0440\u044f\u0435\u043c \u043b\u043e\u0433\u0433\u0435\u0440, \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c, \u043d\u0430\u0437\u043d\u0430\u0447\u0438\u0432 \u0435\u043c\u0443 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044e:<\/p>\n<\/li>\n<\/ol>\n<ul>\n<li>\n<p>\u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 NuGet, \u0435\u0441\u043b\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f, \u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0430\u043a\u0435\u0442 <code>Microsoft.Extensions.Logging.Abstractions<\/code><\/p>\n<\/li>\n<li>\n<p>\u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c <code>readonly<\/code> \u043f\u043e\u043b\u0435:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cs\">private readonly ILogger&lt;WebApiService> _logger; \/\/\u0437\u0434\u0435\u0441\u044c \"WebApiService\" - \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f \u0436\u0443\u0440\u043d\u0430\u043b\u0430, \u0442\u0438\u043f, \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f<\/code><\/pre>\n<ul>\n<li>\n<p>\u0432\u043d\u0435\u0434\u0440\u044f\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cs\">public WebApiService(ILogger&lt;WebApiService> logger) {     _logger = logger; }<\/code><\/pre>\n<ol start=\"3\">\n<li>\n<p>\u0417\u0430\u043f\u0438\u0441\u044c \u0432 \u0436\u0443\u0440\u043d\u0430\u043b:<\/p>\n<pre><code class=\"cs\">_logger.LogDebug($\"{logText}, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0438\u0437 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a: {_settings.SomeParameter}\");<\/code><\/pre>\n<\/li>\n<\/ol>\n<ol start=\"4\">\n<li>\n<p>\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u0446\u0435\u043b\u0438 \u0434\u043b\u044f \u0436\u0443\u0440\u043d\u0430\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438, \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044e \u043b\u043e\u0433 \u0444\u0430\u0439\u043b\u043e\u0432, \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 nlog.config. \u0420\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u043d\u044b\u0439 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 <a href=\"https:\/\/github.com\/SergeyKashkovsky\/WebApiTemplate\/blob\/main\/WebApiTemplate\/nlog.config\" rel=\"noopener noreferrer nofollow\">\u0444\u0430\u0439\u043b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438<\/a> \u0443\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u043b\u043e\u0433-\u0444\u0430\u0439\u043b\u044b \u0437\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 10 \u0434\u043d\u0435\u0439. \u0417\u0430\u043f\u0438\u0441\u044c \u043b\u043e\u0433\u0430 \u0432 \u0444\u0430\u0439\u043b \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u0431\u0438\u0432\u0430\u043b\u043e \u0436\u0443\u0440\u043d\u0430\u043b \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a Microsoft.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <a href=\"http:\/\/localhost:5005\/WeatherForecast\" rel=\"noopener noreferrer nofollow\">http:\/\/localhost:5005\/WeatherForecast<\/a>. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u0437 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0448\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \u0436\u0443\u0440\u043d\u0430\u043b\u0430:<\/p>\n<\/li>\n<\/ol>\n<pre><code>2023-01-06 13:10:45.2375 | INFO | Microsoft.AspNetCore.Hosting.Diagnostics | Request starting HTTP\/1.1 GET http:\/\/localhost:5005\/WeatherForecast - - |  2023-01-06 13:10:45.3266 | DEBUG | WebApiTemplate.Controllers.WeatherForecastController | \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0438\u0437 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a: Some value |  2023-01-06 13:10:45.3266 | DEBUG | WebApiTemplate.Core.Services.WebApiService | \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0443\u0440\u043e\u0432\u043d\u044f \u044f\u0434\u0440\u0430, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0438\u0437 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a: Some value |  2023-01-06 13:10:45.3266 | INFO | WebApiTemplate.Controllers.WeatherForecastController | Action status: Ok |  2023-01-06 13:10:45.3945 | INFO | Microsoft.AspNetCore.Hosting.Diagnostics | Request finished HTTP\/1.1 GET http:\/\/localhost:5005\/WeatherForecast - - - 200 - application\/json;+charset=utf-8 157.2347ms |<\/code><\/pre>\n<p>\u0412 \u0436\u0443\u0440\u043d\u0430\u043b\u0435 \u0432\u0438\u0434\u043d\u043e \u043f\u043e\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440, \u043d\u0430\u0447\u0430\u043b\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430 <code>WebApiTemplate.Controllers.WeatherForecastController.Get<\/code>, \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 <code>WebApiTemplate.Core.Services.WebApiService.SomeAction<\/code>, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0438 \u043e\u0442\u0447\u0435\u0442 \u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 CORS \u043f\u043e\u043b\u0438\u0442\u0438\u043a \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 aspnetcore 6<\/h3>\n<p>\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/metanit.com\/sharp\/aspnet6\/14.2.php\" rel=\"noopener noreferrer nofollow\">\u0421\u0442\u0430\u0442\u044c\u044f \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 Metanit \u043f\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 CORS<\/a><span class=\"habrahidden\">, \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0440\u0435\u0431\u044f\u0442\u0430\u043c \u0437\u0430 \u0442\u043e\u043b\u043a\u043e\u0432\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/span><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/metanit.com\/sharp\/aspnet6\/14.2.php\" rel=\"noopener noreferrer nofollow\">\u0421\u0442\u0430\u0442\u044c\u044f \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 Metanit \u043f\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u043f\u043e\u043b\u0438\u0442\u0438\u043a CORS<\/a><span class=\"habrahidden\">, \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0440\u0435\u0431\u044f\u0442\u0430\u043c \u0437\u0430 \u0442\u043e\u043b\u043a\u043e\u0432\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/span><\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u043c\u043e\u0438\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u043d\u0443\u0436\u0434 \u043e\u0431\u044b\u0447\u043d\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u0432\u0430 \u043d\u0430\u0431\u043e\u0440\u0430 \u043f\u043e\u043b\u0438\u0442\u0438\u043a: \u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438 (\u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043e \u0432\u0441\u0435) \u0438 \u0434\u043b\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 (\u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f)<\/p>\n<ol>\n<li>\n<p>\u0412 appsettings.json \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>AllowedOrigins<\/code>:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"json\">{   ...   \"AllowedOrigins\": [     \"http:\/\/localhost:8080\"   ] }<\/code><\/pre>\n<ol start=\"2\">\n<li>\n<p>\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cs\">\/\/\/ &lt;summary> \/\/\/ \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \/\/\/ &lt;\/summary> public class ApplicationSettings {     ...     \/\/\/ &lt;summary>     \/\/\/ \u0420\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043d\u044b\u0435 \u0434\u043e\u043c\u0435\u043d\u044b - \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0434\u043b\u044f \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438 CORS     \/\/\/ &lt;\/summary>     public string[] AllowedOrigins { get; set; } } <\/code><\/pre>\n<ol start=\"3\">\n<li>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a, \u0432 Program.cs \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0444\u0430\u0439\u043b\u0430 \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c <code>builder<\/code> \u0438 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0441\u0431\u043e\u0440\u043a\u0438 Web \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f <code>var app = builder.Build();<\/code>:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cs\">var settings = builder.Configuration.Get&lt;ApplicationSettings>() ?? throw new ArgumentNullException(\"ApplicationSettings\", \"\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0430\");<\/code><\/pre>\n<ol start=\"4\">\n<li>\n<p>\u0412 Program.cs \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c CORS \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438 \u0434\u043e \u0432\u044b\u0437\u043e\u0432\u0430 <code>builder.Build()<\/code><\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cs\">    builder.Services.AddCors(options => options.AddPolicy(\"AllowAny\", builder => builder         .AllowAnyOrigin()         .AllowAnyHeader()         .AllowAnyMethod())     );      builder.Services.AddCors(options => options.AddPolicy(\"AllowSome\", builder => builder         .WithOrigins(settings.AllowedOrigins)         .AllowAnyHeader()         .AllowAnyMethod()         .AllowCredentials())     );<\/code><\/pre>\n<ol start=\"5\">\n<li>\n<p>\u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0438\u043f\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (Debug \u0438\u043b\u0438 Release), \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0442\u0443 \u0438\u043b\u0438 \u0438\u043d\u0443\u044e \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0443 \u0432 \u0444\u0430\u0439\u043b\u0435 Program.cs \u043c\u0435\u0436\u0434\u0443 <code>var app = builder.Build();<\/code> \u0438 <code>app.Run();<\/code>:<\/p>\n<\/li>\n<\/ol>\n<pre><code>#if DEBUG     app.UseCors(\"AllowAny\"); #else<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-343586","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/343586","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=343586"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/343586\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=343586"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=343586"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=343586"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}