• <small id='RuMHH'></small><noframes id='RuMHH'>

        <bdo id='RuMHH'></bdo><ul id='RuMHH'></ul>

      1. <i id='RuMHH'><tr id='RuMHH'><dt id='RuMHH'><q id='RuMHH'><span id='RuMHH'><b id='RuMHH'><form id='RuMHH'><ins id='RuMHH'></ins><ul id='RuMHH'></ul><sub id='RuMHH'></sub></form><legend id='RuMHH'></legend><bdo id='RuMHH'><pre id='RuMHH'><center id='RuMHH'></center></pre></bdo></b><th id='RuMHH'></th></span></q></dt></tr></i><div id='RuMHH'><tfoot id='RuMHH'></tfoot><dl id='RuMHH'><fieldset id='RuMHH'></fieldset></dl></div>

        <tfoot id='RuMHH'></tfoot>
      2. <legend id='RuMHH'><style id='RuMHH'><dir id='RuMHH'><q id='RuMHH'></q></dir></style></legend>

        在 ASP.NET 页面中查找客户端位置

        Finding clients location in an ASP.NET page(在 ASP.NET 页面中查找客户端位置)
      3. <i id='Luqrg'><tr id='Luqrg'><dt id='Luqrg'><q id='Luqrg'><span id='Luqrg'><b id='Luqrg'><form id='Luqrg'><ins id='Luqrg'></ins><ul id='Luqrg'></ul><sub id='Luqrg'></sub></form><legend id='Luqrg'></legend><bdo id='Luqrg'><pre id='Luqrg'><center id='Luqrg'></center></pre></bdo></b><th id='Luqrg'></th></span></q></dt></tr></i><div id='Luqrg'><tfoot id='Luqrg'></tfoot><dl id='Luqrg'><fieldset id='Luqrg'></fieldset></dl></div>

      4. <legend id='Luqrg'><style id='Luqrg'><dir id='Luqrg'><q id='Luqrg'></q></dir></style></legend><tfoot id='Luqrg'></tfoot>

            <tbody id='Luqrg'></tbody>
              • <small id='Luqrg'></small><noframes id='Luqrg'>

                  <bdo id='Luqrg'></bdo><ul id='Luqrg'></ul>
                  本文介绍了在 ASP.NET 页面中查找客户端位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如何在我的 ASP.NET 页面中找到客户端位置?事实上,我使用了 System.Globalization.RegionInfo.CurrentRegion,但它在控制面板中显示了设置.那么我可以使用任何方法找到确切的位置吗?

                  How to find clients location in my ASP.NET page? In fact I used System.Globalization.RegionInfo.CurrentRegion, but it is showing the setting in the control panel. So can I find the exact location using any method?

                  推荐答案

                  并不是说它会给你 100% 的准确率,但是你可以使用 hostip.info

                  Not that it would give you 100% accuracy, but you can use hostip.info

                  他们提供了一个 API,可以为您提供通过 HTTP 请求传递给他们的 IP 地址的位置.您可以使用 WebClient 对象来调用 API 并解析结果.Scott Hanselman 在 这篇博文中有一个非常棒的例子(我下面的例子是基于他的文章).hostip.info 的数据库基于社区提供 IP 位置的一个开放项目......所以不能保证是正确的.

                  They provide an API that gives you the location of an IP address that you pass them via HTTP request. You can use a WebClient object to make calls to the API and parse the results. Scott Hanselman has a pretty great example in this blog article (my example below is based on his article). hostip.info's database is based on an open project that the community contributes IP locations to... so there is no guarantee to be correct.

                  对于初学者,您需要按如下方式确定客户端 IP 地址:

                  For starters, you need to determine the client IP address as follows:

                  string ipaddress = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
                  

                  获得 IP 后,您可以创建 WebClient 对象并调用 API...

                  Once you have the IP, you can create a WebClient object and call the API...

                  示例 API 调用:

                  string r;
                  using (var w = new WebClient())
                  {
                      r = w.DownloadString(String.Format("http://api.hostip.info/?ip={0}&position=true", ipaddress));
                  }
                  

                  结果将是如下所示的 XML:

                  The results will be XML that looks something like this:

                  <?xml version="1.0" encoding="ISO-8859-1" ?>
                  <HostipLookupResultSet version="1.0.0" xmlns="http://www.hostip.info/api" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.hostip.info/api/hostip-1.0.0.xsd">
                   <gml:description>This is the Hostip Lookup Service</gml:description>
                   <gml:name>hostip</gml:name>
                   <gml:boundedBy>
                      <gml:Null>inapplicable</gml:Null>
                   </gml:boundedBy>
                   <gml:featureMember>
                      <Hostip>
                       <gml:name>Sugar Grove, IL</gml:name>
                       <countryName>UNITED STATES</countryName>
                       <countryAbbrev>US</countryAbbrev>
                       <!-- Co-ordinates are available as lng,lat -->
                       <ipLocation>
                          <gml:PointProperty>
                           <gml:Point srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
                              <gml:coordinates>-88.4588,41.7696</gml:coordinates>
                           </gml:Point>
                          </gml:PointProperty>
                       </ipLocation>
                      </Hostip>
                   </gml:featureMember>
                  </HostipLookupResultSet>
                  

                  这篇关于在 ASP.NET 页面中查找客户端位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  C# namespace alias - what#39;s the point?(C# 命名空间别名 - 有什么意义?)
                  Using Xpath With Default Namespace in C#(在 C# 中使用具有默认命名空间的 Xpath)
                  Generating an EDMX from a DB2 Database(从 DB2 数据库生成 EDMX)
                  Using entity Framework with .NET Core and DB2(将实体框架与 .NET Core 和 DB2 结合使用)
                  IBM .NET Data Provider Connection String issue with Library List(库列表的 IBM .NET 数据提供程序连接字符串问题)
                  .NET DB2 OLEDB pre-requisites(.NET DB2 OLEDB 先决条件)

                • <legend id='SVBce'><style id='SVBce'><dir id='SVBce'><q id='SVBce'></q></dir></style></legend>

                      <small id='SVBce'></small><noframes id='SVBce'>

                        <tbody id='SVBce'></tbody>
                    • <tfoot id='SVBce'></tfoot>

                        <bdo id='SVBce'></bdo><ul id='SVBce'></ul>

                          1. <i id='SVBce'><tr id='SVBce'><dt id='SVBce'><q id='SVBce'><span id='SVBce'><b id='SVBce'><form id='SVBce'><ins id='SVBce'></ins><ul id='SVBce'></ul><sub id='SVBce'></sub></form><legend id='SVBce'></legend><bdo id='SVBce'><pre id='SVBce'><center id='SVBce'></center></pre></bdo></b><th id='SVBce'></th></span></q></dt></tr></i><div id='SVBce'><tfoot id='SVBce'></tfoot><dl id='SVBce'><fieldset id='SVBce'></fieldset></dl></div>