How to get cookie in Web API in a Forms Authentication scenario in Cross Application?

4

I have the following .Net applications:

  • Web Application with Forms Authentication (I'm not using the MVC, I use Backbone.js to make calls to the REST API)
  • Web Application REST API sharing the same Forms Authenticaion used in application 1.
  • I am using the same machineKey in both projects so the cookie is unique in both. Reference

    The single cookie settings in both applications seem to be working (I'm not sure), but how do I get the cookie in the Web API application?

        
    asked by anonymous 07.07.2016 / 15:31

    2 answers

    1

    To get the cookie in a WebApi controller just use Request.Headers.GetCookies('nome do cookie')

        
    14.01.2017 / 22:15
    0

    This will only be possible if both applications are on the same server and sharing the same virtual directory.

    Any scenario other than this will not be possible. So if you're hosting in the cloud, you can discard it.

    If you have met the criteria above, just set the PATH of the cookie to / and ready, both applications will consume the same cookies.

        
    07.07.2016 / 17:05