Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

if session is not active then redirect to login page mvc.net

public class AuthorizeActionFilterAttribute : ActionFilterAttribute
    {
      public override void OnActionExecuting(FilterExecutingContext filterContext)
      {
        HttpSessionStateBase session = filterContext.HttpContext.Session;
        Controller controller = filterContext.Controller as Controller;

        if (controller != null)
        {
          if (session != null && session ["authstatus"] == null)
          {
filterContext.Result =
       new RedirectToRouteResult(
           new RouteValueDictionary{{ "controller", "Login" },
                                          { "action", "Index" }

                                         });
          }
        }

        base.OnActionExecuting(filterContext);
      }
    }
more details in here:

https://stackoverflow.com/a/5453371/1384539

Comment

PREVIOUS NEXT
Code Example
Csharp :: create anchor tag dynamically c# 
Csharp :: dotnet core clickable row 
Csharp :: c# webbrowser upload file 
Csharp :: c#, get a embedded resx file 
Csharp :: Count Rows of table using Linq 
Csharp :: list of vectors c# 
Csharp :: How do I identify the referrer page in ASP.NET? 
Csharp :: singleton pattern c# stack overflow 
Csharp :: Code snipet for jump script unity 2d 
Csharp :: insert button in c# 
Csharp :: asp.net core 6 get current culture in controller 
Csharp :: c # 
Csharp :: how to cut image from timeline editor in c# 
Csharp :: c# base vs this 
Csharp :: c# check value at design time 
Csharp :: copy file image in c# 
Csharp :: mvc dotnet core how does the view pass parameters to controler 
Csharp :: generate poco from db efcore 
Csharp :: aps.net core mvc chek box 
Csharp :: Deserialize a Dictionary 
Csharp :: finding holydays asp.net 
Csharp :: How to execute a script after the c# function executed 
Csharp :: sequelize instance method is not a function 
Csharp :: Difference between IHostingEnvironment and IWebHostEnvironment ? 
Csharp :: c# message box carriage return 
Csharp :: "??" in C# 
Csharp :: how to preset an array c# 
Csharp :: binance slp to php 
Csharp :: parallelism in c# 
Csharp :: c# string replace multiple matches with one charactar 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =