I have an edit page I want to use to allow editing of user details. When I update some user details and post on my dev machine it works as expected, details are saved to the DB and I am re-directed to the details page which displays the updated information.
When I publish the site to the live server and perform the same actions it basically doesn't come away from the edit page. The only time the page will successfully post and re-direct is if none of the details are changed from the original values.
Here is the code for the posting:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Edit(int id, FormCollection formValues)
{
var repo = new UserRepository();
var user = repo.GetById(id);
try
{
double value;
foreach(var stat in user.Stats)
{
var rawValue = formValues[stat.Name];
if (Double.TryParse(rawValue, out value))
{
stat.Value = value;
}
else
{
ModelState.AddModelError(stat.Name+"Err", "Value must be numerical.");
}
}
UpdateModel(user);
if (ModelState.IsValid)
{
repo.Save();
return RedirectToAction("details", new { id = user.ID });
}
else
throw new InvalidOperationException();
}
catch
{
foreach (var issue in user.GetRuleViolations())
{
ModelState.AddModelError(issue.PropertyName, issue.ErrorMessage);
}
return View(user);
}
}
I am on windows server 2003 + IIS 6.0