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



我正在通过Visual Studio运行ASP.NET应用程序。纬度和经度数据是从SQL Server数据库中检索的。该应用程序在通过VisualStudiolocalhost运行时不会出现任何问题,但当我将其部署到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本地主机。

IIS服务器

IIS服务器控制台.log输出

为了任何有同样问题的人的利益。问题出在ASP.NET应用程序中的区域设置上。默认情况下,它设置为逗号。对我有用的一个方法是将值设置为以"."作为分隔符的字符串格式。

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

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

相关内容

最新更新