ASP.Net 过滤器
2021-01-18 18:16
标签:gif over headers code app ali ada default request 授权过滤器 结果过滤器 ASP.Net 过滤器 标签:gif over headers code app ali ada default request 原文地址:https://www.cnblogs.com/XJNB/p/13343127.htmlusing System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;
using WebApplication17.Models;
using Newtonsoft.Json;
using System.Net.Http;
namespace WebApplication17.Models
{
public class MyAuthrizeAttribute:AuthorizeAttribute
{
public override void OnAuthorization(HttpActionContext actionContext)
{
//base.OnAuthorization(actionContext);
if (actionContext.Request.Headers.Contains("BWAUTH"))
{
var headers = actionContext.Request.Headers.GetValues("BWAUTH");
JWTHelper helper = new JWTHelper();
string playload = helper.GetPayload(headers.FirstOrDefault());
UserInfo user = JsonConvert.DeserializeObject
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http.Filters;
using System.Net.Http;
using Newtonsoft.Json;
namespace WebApplication17.Models
{
public class BWActionFilterAttribute:ActionFilterAttribute
{
public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
{
var result = actionExecutedContext.ActionContext.Response.Content.ReadAsAsyncobject>().Result;
BWActionResult data = new BWActionResult() { Code = 0, Msg = "Ok", Data = result };
actionExecutedContext.Response.Content = new StringContent( JsonConvert.SerializeObject(data), System.Text.Encoding.UTF8,"application/json" );
}
}
}