Exemplo n.º 1
0
        public IActionResult Login(LoginInputDto input)
        {
            if (!CheckPwd(input))
            {
                return(Json(new ResultDto()
                {
                    Message = "invalid username or password"
                }));
            }
            var token = JwtHelper.GenerateJwtToken(options.Secret, new Dictionary <string, string>
            {
                { "username", input.UserName },
                { "logintime", DateTime.Now.ToString() }
            });

            ResponseCookie.Add(new HttpCookie
            {
                Name  = "authorization",
                Value = token
            });
            return(Json(new ResultDto()
            {
                Success = true
            }));
        }
Exemplo n.º 2
0
        public void GET()
        {
            //request 请求
            HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(url);

            webReq.CookieContainer = RequestCookie;//存储网页返回的cookie值
            webReq.Method          = Method;
            //response 返回
            HttpWebResponse webResp = (HttpWebResponse)webReq.GetResponse();

            ResponseCookie.Add(webResp.Cookies);
            //获取返回的response流
            using (Stream stream = webResp.GetResponseStream())
            {
                using (StreamReader read = new StreamReader(stream, Encoder))
                {
                    html = read.ReadToEnd();
                }
            }
        }