Translate

Wednesday, 18 November 2015

Check Login session before every action hitting in MVC



Here is checking the session values every time when before hitting to every action.



  protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (Session["User"] != null)
            {
                base.OnActionExecuting(filterContext);
            }
            else
            {
                TempData["TimeOut"] = "Please login again.";
                filterContext.Result = RedirectToAction("Index", "Home", new { area = "" });
            }

        }

3 comments:

  1. Hi Kavitha your posts are good
    But if possible can u plz post some JQGrid Using External Search & CheckBox, RadioButtons & some achor tags etc...
    It will be helpful for us...

    ReplyDelete
  2. Hi Uttar,

    I have already placed checkbox, anchor tag in JqGrid. instead of checkbox you can place radio button. For external search you can place a taxtbox out side grid and when textbox change/blur event with jquery you can hit the actionresult and again you can bind the Grid with searchresult.

    if any doubts ask me.

    ReplyDelete
  3. For your reference see my post in below URL

    http://mygoldenmvc.blogspot.in/2015/04/how-to-use-jqgrid-aspnet-mvc.html

    ReplyDelete