部署到IIS的ASP .NET Core应用程序,但是经纬度在部署到IIS的应用程序上没有小数点

我正在通过Visual Studio运行ASP .NET应用程序。纬度和经度数据是从SQL Server数据库中检索的。通过Visual Studio本地主机运行时,该应用程序可以正常工作,但是当我将其部署到IIS时,显示的数据没有小数点。

数据库中的数据类型为浮点数。

TestTable模态类,用于从数据库中检索数据。

public class TestTable
{
    public int ID { get; set; }
    public string Product_Description { get; set; }
    public int PolicyNo { get; set; }
    public string Insured { get; set; }
    public string TAB_Ratio { get; set; }
    public string Broker_Name { get; set; }
    public DateTime Policy_Inception_Date { get; set; }
    public string Match { get; set; }
    public string Detail_Address { get; set; }
    public int Building_SI { get; set; }
    public decimal Total_API_Outside { get; set; }
    public decimal Rate { get; set; }
    public decimal Total_Loss_Ratio { get; set; }
    public decimal ThrdParty_Loss_ratio { get; set; }
    public decimal ThrdParty_Attritional_Ratio { get; set; }
    public double Lat { get; set; }
    public double Long { get; set; }
}

Foreach从TestTable检索数据

@{ var mapCounter = 0;}
@foreach (var item in Model.TestTable) {
   if(mapCounter < 200)
   {
      mapCounter++;
      <text>
         console.log(@item.Lat);
      </text>
      @:addMarker(@item.Lat,@item.Long,'@item.ID','@item.Product_Description','@item.Insured','@item.TAB_Ratio','@item.Broker_Name','@item.PolicyNo','@item.Match','@item.Detail_Address','@item.Building_SI','@item.Total_API_Outside','@item.Rate','@item.Total_Loss_Ratio','@item.ThrdParty_Loss_ratio','@item.ThrdParty_Attritional_Ratio');
     }
 }

基于数据库数据创建标记的功能

 function addMarker(latitude,longitude,title,description,insured,tab_ratio,broker_name,policy_inception,match,detail_address,building_si,total_api_outside,rate,total_loss_ratio,thrdparty_loss_ratio,thrdparty_attritional_ratio)
 {
     var latLng = new google.maps.LatLng(latitude,longitude);

     var marker = new google.maps.Marker({
         position: latLng,title: title,map: map,icon: icon,draggable: false
     });

     allMarkers.push(marker);
 }

请参阅控制台以获取输出。

Visual Studio的顶部图像。 IIS服务器的底部图像。

谢谢。

Visual Studio Localhost

IIS Server

IIS Server console.log output

jjjjcccchhhh 回答:部署到IIS的ASP .NET Core应用程序,但是经纬度在部署到IIS的应用程序上没有小数点

为了所有人的共同利益。问题在于ASP .NET应用程序中的区域设置。默认情况下,它设置为逗号。对我而言,一种解决方法是将值设置为带有“。”的字符串格式。作为分隔符。

using System.Globalization;

console.log(@string.Format(CultureInfo.InvariantCulture,"{0:#.#############################}",item.Lat));
console.log(@string.Format(CultureInfo.InvariantCulture,item.Long));

无论机器设置在哪个区域设置上,这都会将区域号格式设置为应用程序。

本文链接:https://www.f2er.com/3138655.html

大家都在问