42 lines
1.0 KiB
C#
42 lines
1.0 KiB
C#
|
|
using Newtonsoft.Json;
|
|||
|
|
using Org.BouncyCastle.Utilities;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Web;
|
|||
|
|
using System.Web.Mvc;
|
|||
|
|
|
|||
|
|
namespace MQTTServerSideAPI.Controllers
|
|||
|
|
{
|
|||
|
|
public class BaseController : Controller
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 在Action方法调用前使用,使用场景:如何验证登录等。
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="filterContext"></param>
|
|||
|
|
protected override void OnActionExecuting(ActionExecutingContext filterContext)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
base.OnActionExecuting(filterContext);
|
|||
|
|
if (Session["username"] == null)
|
|||
|
|
{
|
|||
|
|
filterContext.Result = new RedirectResult("/LoginViews/Index");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
Logger.LogCalloutanaSide("Session:__________________" + ex);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|