初始化
This commit is contained in:
42
MQTTServerSideAPI/Controllers/BaseController.cs
Normal file
42
MQTTServerSideAPI/Controllers/BaseController.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user