Following is the exact scenario in my application:
- I generate a GUID in an controller action.
- The GUID is stored in TempData.
- I pass the GUID along with a ViewModel in a razor view (MyView.cshtml) that gets opened from that controller action.
A view is having a hiddenfield which is bound with the GUID.
@Html.HiddenFor(m => m.CustomGuid)
There is another controller action which returns a Json result containing the GUID value in TempData.
[HttpGet] public ActionResult GetGuid() { string result = String.Empty; if (GetTempData("mGuid") != null) { result = GetTempData("mGuid").ToString(); } else { result = "INVALID_SESSION"; } return Json(result, JsonRequestBehavior.AllowGet); }
I have written following jquery in MyView.cshtml
$.get('@Url.Action("GetGuid", "Controller")', function (result) {
if (result.toString().toLowerCase() == $('#CustomGuid').val().toString().toLowerCase()) { alert('ok'); } else { alert('Invalid Identifier.'); window.location = '@Url.Action("ShowErrorPage", "Controller")'; return false; } });
The problem is that, it works fine in IE and Firefox, but it always has a different GUID in the TempData and HiddenField, and so everytime giving a message of "Invalid identifier"
What could be the reason? Why this behavior could be different in Chrome?