Question

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?

Was it helpful?

Solution

I found that, a resource (simply a light-weight CSS) file was missing on the server. However, that CSS had no significance in the website, but Chrome reloads the page if any of the resource is not found, whereas IE and Firefox simply ignores. Having said that, I could manage to fix this by removing reference of that CSS (which was absolutely not required in my application)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top