asp.net MVC3 JQuery隐藏字段未发布

时间:2011-12-06 03:35:06

标签: jquery asp.net-mvc-3

请注意,我的计算机上的代码运行正常,但发布到我的托管服务提供商时,隐藏的数据未发布

我有一个表单,你设置地址,谷歌地图然后获取lat / lng和jquery将设置隐藏字段中的值

但发布时,该值不会发送到服务器

我甚至尝试了Request [“Lat”]并且没有发送任何内容

在本地计算机上运行相同的代码时工作正常,可能是配置问题吗?我没有看到它。

由于

这是代码的一部分 网页

...
@using (Html.BeginForm("Register","Account")) // same error without the action and controller specified

....
 @Html.TextBoxFor(m => m.Address, new { maxlength = "200" })
.....
@Html.HiddenFor(m => m.Lat)
@Html.HiddenFor(m => m.Lng)
....

在js

...
$('#Address').blur(function () {
        $('#Address').val($('#Address').val().toUpperCase());
        codeAddress();
        drawCircle();
    });
...
function codeAddress() {
    if ($('#Address').val() == '')
        return;

    var address = $('#Address').val() + ', CA';
    if (geocoder) {
        geocoder.geocode({ 'address': address }, function (results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                $('#Lat').val(results[0].geometry.location.lat());
                $('#Lng').val(results[0].geometry.location.lng());
                //alert($('#Lat').val() + ', ' +$('#Lng').val())
                map.setCenter(results[0].geometry.location);
                drawCircle();
            } else {
                alert("Geocode was not successful for the following reason: " + status);
            }
        });
    }
}
....

此时警报显示新的lat,lng

发布时,发布了默认的空白

我的问题是为什么它总是在我的开发机器上工作而不是在我的共享主机上?

更新:似乎默认绑定器没有绑定,为什么它在本地工作但不在实时服务器上?

新更新: 实际上,我可以在firebug中看到该表格 我的控制器说没有收到任何表格数据 我的日志表明没有发布数据

它也会在登录时发生,其中只发送用户名,密码并记住我 任何想法都会有所帮助

@Html.ValidationSummary(true, @sResources.Strings.LogOnUnsuccessful)
@using (Html.BeginForm("LogOn", "Account"))
{
    <div>
        <fieldset>
            <legend>Account Information</legend>
            <div class="editor-label">
                @Html.LabelFor(m => m.UserName)
            </div>
            <div class="editor-field">
                @Html.TextBoxFor(m => m.UserName, new { style = " width:200px" })
                @Html.ValidationMessageFor(m => m.UserName)
            </div>
            <div class="editor-label">
                @Html.LabelFor(m => m.Password)
            </div>
            <div class="editor-field">
                @Html.PasswordFor(m => m.Password, new { style = " width:200px" })
                @Html.ValidationMessageFor(m => m.Password)
            </div>
            <div class="editor-label">
                @Html.CheckBoxFor(m => m.RememberMe)
                @Html.LabelFor(m => m.RememberMe)
            </div>
            <p>
                <input type="submit" value="@sResources.Strings.LogOn" />
            </p>
        </fieldset>
    </div>
}


       [HttpGet]
            public ActionResult LogOn()
            {
                return View();
            }

            [HttpPost]
            public ActionResult LogOn(LogOnModel model, string returnUrl)
            {
                //LogOnModel model = new LogOnModel() { UserName = UserName, Password = Password, RememberMe = RememberMe.HasValue ? RememberMe.Value : false };
                if (model != null)
                    Log(new Exception(string.Format("model username : {0}, password : {1}, request[username] {2} , request[password] : {3}", model.UserName, model.Password, Request["UserName"], Request["Password"])));
                try...

其中model.UserName和model.Password为空

为什么模型为空

1 个答案:

答案 0 :(得分:1)

加载fiddler并查找正在发布的字段。如果它不存在,那么检查浏览器开发人员工具中的表单元素值。如果没有设置则不会发布。此外,当您部署它时请注意,跨域帧无法读取其他数据,因此,如果您尝试从其他倾斜域读取帧或iframe值,则此操作将失败。

相关问题