Reputation: 6858
note that the code works fine on my machine but when published to my hosting provider the hidden data is not being posted
I have a form where you set the address, google maps then gets the lat/lng and jquery will set the value in the hidden field
but when posted the value are not sent to the server
I even tried Request["Lat"] and nothing is sent
When running the same code on my local machine it works fine, could it be a configuration problem? I don't see it.
Thanks
here is part of the code webpage
...
@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)
....
in 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);
}
});
}
}
....
at this point the alert shows the new lat,lng
when posted the default 0 of empty is posted
My question is why would it always work on my dev machine and not on my shared hosting?
UPDATE : it seems like the defaultbinder is not binding, why would it work locally but not on live server?
New Update: Actually the form is being posted I can see in firebug My controller says that no form data was received though my log indicates no post data
it happens also on the log on, where only username, password and remember me are sent any idea would help
@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...
where model.UserName and model.Password is empty
why is the model empty
Upvotes: 1
Views: 1224
Reputation: 30152
Load up fiddler and look for the field being posted. If it's not there then inspect the form elements value in the browsers developer tools. If it's not set then it won't get posted. Also when you deployed it note that cross domain frames can't read each others data so if you are trying to read a frame or iframes value from a different tilt domain this will fail.
Upvotes: 1