Try this
LINK[
^]
and this link also
LINK[
^]
You can use a ActionFilter that looks something like this:
public class RefreshDetectFilter : IActionFilter
{
public void OnActionExecuting(ActionExecutingContext filterContext)
{
var cookie = filterContext.HttpContext.Request.Cookies["RefreshFilter"];
filterContext.RouteData.Values["IsRefreshed"] = cookie != null &&
cookie.Value == filterContext.HttpContext.Request.Url.ToString();
}
public void OnActionExecuted(ActionExecutedContext filterContext)
{
filterContext.HttpContext.Response.SetCookie(new HttpCookie("RefreshFilter", filterContext.HttpContext.Request.Url.ToString()));
}
}
Register it in global.asax. Then you can just do this in your controller:
if (RouteData.Values["IsRefreshed"] == true)
{
// page has been refreshed.
}
You might want to improve the detection to also check the HTTP Method used (as a POST and GET url can look the same). Do note that it uses a cookie for the detection.