我正在开发一个 asp.net mvc 门户来使用 localDB 管理 GPS 坐标。我的模型是:
public class GpsCoordinateViewModel
{
double Latitute { get; set; }
double Longitude { get; set; }
}
用于创建新 GpsCoordinate 的自动生成的广告相关视图是:
@{
ViewBag.Title = "Create";
}
<h2>Create</h2>
@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset>
<legend>GpsCoordinateViewModel</legend>
<div class="editor-label">
@Html.LabelFor(model => model.Latitude)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Latitude)
@Html.ValidationMessageFor(model => model.Latitude)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Longitude)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Longitude)
@Html.ValidationMessageFor(model => model.Longitude)
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
问题是,当我插入纬度:41.213321 和经度:12.123432(例如)时,使用断点本地值是:纬度:41213321 经度:12123432。由于位置的准确性,我需要使用双精度,但是如何?
我还阅读了这个问题: 我应该如何在 MVC 中使用 EditorFor() 作为货币/货币类型?
但解决方案对我不起作用。有什么建议吗?
编辑:我的网络配置是:
<system.web>
<httpHandlers>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>
<!--
Enabling request validation in view pages would cause validation to occur
after the input has already been processed by the controller. By default
MVC performs request validation before a controller processes the input.
To change this behavior apply the ValidateInputAttribute to a
controller or action.
-->
<pages
validateRequest="false"
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=number">
<controls>
<add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=number" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
<globalization culture="en-US" uiCulture="en-US" />