ASP.Net 登录控制器

2021-01-18 18:13

阅读:623

标签:ring   web   span   info   sys   http   filter   bsp   lin   

技术图片技术图片
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using WebApplication17.Models;

namespace WebApplication17.Controllers
{
    [BWActionFilter]
    [MyAuthrize]
    public class DefaultController : ApiController
    {
       
        public int get()
        {
            return 1;
        }
    }
}
View Code

 

技术图片技术图片
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using WebApplication17.Models;

namespace WebApplication17.Controllers
{
    public class AccountController : ApiController
    {
        public string Login(UserInfo user)
        {
            string token = "";
            if (user.Name == "Admin" && user.Pass == "1234")
            {
                JWTHelper helper = new JWTHelper();
                Dictionarystring, object> playload = new Dictionarystring, object>();
                playload.Add("Name", user.Name);
                playload.Add("Id", user.Id);
                token =helper.GetToken(playload, 1200);
            }
            return token;
        }
    }
}
View Code

 

ASP.Net 登录控制器

标签:ring   web   span   info   sys   http   filter   bsp   lin   

原文地址:https://www.cnblogs.com/XJNB/p/13343131.html

上一篇:文件上传下载

下一篇:ASP.Net 过滤器


评论


亲,登录后才可以留言!