How to store token in mvc cookie and send it to ap

2019-08-12 15:47发布

I am sending credentials to API which creates user then through MVC Login method i create token in Web API and return token in response to MVC now I want to store Token in MVC Cookie and again send it Web API when hitting API Controller authorized action.

Please suggest me these two things

1条回答
狗以群分
2楼-- · 2019-08-12 16:25

There's not a whole lot to work with here, but generally speaking, Web API diverges from MVC mostly in that it's fully REST-compliant, whereas MVC is not. REST-compliant applications are stateless (in other words: no session, no cookies, etc.). Everything the API endpoint needs must be sent along with the request either in the URL, the request headers or the request body. That means you could send the value of the cookie (not the cookie, itself) in the query string of a GET request or the body of a POST, or as is typical with REST API auth, as an Authorization HTTP header.

查看更多
登录 后发表回答