开发者

MVC Website as Restful API With Authentication

开发者 https://www.devze.com 2023-02-12 13:01 出处:网络
I have a MVC .NET application that I would like to expose to our clients as an API.Can I just apply a filter to switch the serialization.I\'ve seen examples of how to auto switch the output using acti

I have a MVC .NET application that I would like to expose to our clients as an API. Can I just apply a filter to switch the serialization. I've seen examples of how to auto switch the output using action filters, but had questions on authentication.

The system currently uses forms authentication, and auto redirects if no authentication is provided.

Can I just use the authentication as is and require the client system to login, perform functionality and logout just as if they were using the system via web brows开发者_C百科er?


Depending on your authentication mechanism, you would be requiring the client to hang on to cookie values just like a browser would. It should work though. You could also implement a custom authentication filter that does token based stuff or the regular stuff depending on the client.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号