﻿
{"id":5963,"date":"2017-04-12T14:19:39","date_gmt":"2017-04-12T14:19:39","guid":{"rendered":"http:\/\/www.gencayyildiz.com\/blog\/?p=5963"},"modified":"2017-04-12T14:19:39","modified_gmt":"2017-04-12T14:19:39","slug":"asp-net-mvc-ile-kullanicinin-ip-adresini-alma","status":"publish","type":"post","link":"https:\/\/www.gencayyildiz.com\/blog\/asp-net-mvc-ile-kullanicinin-ip-adresini-alma\/","title":{"rendered":"Asp.NET MVC \u0130le Kullan\u0131c\u0131n\u0131n IP Adresini Alma"},"content":{"rendered":"<div id=\"fb-root\"><\/div>\n<p>Merhaba,<\/p>\n<p>\u0130\u00e7eri\u011fimizin ba\u015fl\u0131\u011f\u0131nda her ne kadar Asp.NET MVC&#8217;ye de\u011finilmi\u015f olunsada asl\u0131nda Asp.NET Web Forms mimarisinde de uygulayabilece\u011finiz bir kod demecinden bahsedece\u011fim.<\/p>\n<p>A\u015fa\u011f\u0131da vermi\u015f oldu\u011fum kod blo\u011fundaki yap\u0131 sayesinde ilgili kullan\u0131c\u0131n\u0131n do\u011fruluk pay\u0131 en y\u00fcksek olan IP adresini elde edebilirsiniz. Koda g\u00f6z atarsan\u0131z e\u011fer g\u00f6receksiniz ki &#8220;Load Balancer-Y\u00fck Dengeleme&#8221; yahut y\u00f6nlendirme gibi olas\u0131 durumlar\u0131 g\u00f6ze alarak belirli kontroller sa\u011flan\u0131p en do\u011fru IP adresi elde edilmeye \u00e7al\u0131\u015f\u0131lm\u0131\u015ft\u0131r.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n        public static string GetClientIp()\r\n        {\r\n            var ipAddress = string.Empty;\r\n            if (HttpContext.Current.Request.ServerVariables&#x5B;&quot;HTTP_X_FORWARDED_FOR&quot;] != null)\r\n                ipAddress = HttpContext.Current.Request.ServerVariables&#x5B;&quot;HTTP_X_FORWARDED_FOR&quot;].ToString();\r\n            else if (HttpContext.Current.Request.ServerVariables&#x5B;&quot;HTTP_CLIENT_IP&quot;] != null &amp;&amp; HttpContext.Current.Request.ServerVariables&#x5B;&quot;HTTP_CLIENT_IP&quot;].Length != 0)\r\n                ipAddress = HttpContext.Current.Request.ServerVariables&#x5B;&quot;HTTP_CLIENT_IP&quot;];\r\n            else if (HttpContext.Current.Request.UserHostAddress.Length != 0)\r\n                ipAddress = HttpContext.Current.Request.UserHostName;\r\n            return ipAddress;\r\n        }\r\n<\/pre>\n<p>Sevgiler&#8230;<br \/>\n\u0130yi \u00e7al\u0131\u015fmalar&#8230;<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Merhaba, \u0130\u00e7eri\u011fimizin ba\u015fl\u0131\u011f\u0131nda her ne kadar Asp.NET MVC&#8217;ye de\u011finilmi\u015f olunsada asl\u0131nda Asp.NET Web Forms mimarisinde de uygulayabilece\u011finiz bir kod demecinden bahsedece\u011fim. A\u015fa\u011f\u0131da vermi\u015f oldu\u011fum kod blo\u011fundaki yap\u0131 sayesinde ilgili kullan\u0131c\u0131n\u0131n do\u011fruluk pay\u0131 en y\u00fcksek&#46;&#46;&#46;<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":3223,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,11],"tags":[745,1714,746,1713,304,1715,283,552,1716],"class_list":["post-5963","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-asp-net","category-asp-net-mvc","tag-asp-net","tag-asp-net-ip","tag-asp-net-mvc","tag-asp-net-mvc-web-forms","tag-ip","tag-load-balancer","tag-mvc","tag-web-forms","tag-yuk-dengeleme"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/5963","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/comments?post=5963"}],"version-history":[{"count":0,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/5963\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media\/3223"}],"wp:attachment":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media?parent=5963"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/categories?post=5963"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/tags?post=5963"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}