asp.net web api - WebApi and MVC in different projects, share cookies? -


i've separated webapi project mvc project (http://mydomain.com) , webapi project (http://api.mydomain.com).

my mvc project manages authentication , service views (which use knockoutjs , ajax).

my problem cookies mvc project not sent when requesting information webapi domain (using ajax). or rather, during testing i'm using 2 iis express servers on different parts.

the project going deployed azure later, solution must work between 2 web sites.

so how can cookies sent through? or should switch use kind of token instead?

edit

it works until add contenttype $.ajax request. cors preflight option then. answer 200 think correct headers. if remove option working request cookies again.

works

$.ajax({     url: "http://localhost:54304/organization/",     type: "post",     data: "$top=10",     xhrfields: {         withcredentials: true     },     crossdomain: true,     success: function (data) { console.log(data); } }); 

do not work:

$.ajax({     url: "http://localhost:54304/organization/",     contenttype: 'application/json', //<--- triggers preflight     type: "post",     data: "$top=10",     xhrfields: {         withcredentials: true     },     crossdomain: true,     success: function (data) { console.log(data); } }); 

now jquery "feature" or how cors works? headers should set? i've tried reply with:

access-control-allow-credentials:true access-control-allow-origin:http://localhost:51343 

when set cookie, set domain names cookie should apply to.
cookies depend on domain names (and optionally paths); not on kind of server have.

in case, can set domain .mydomain.com, wildcard cookie sent root domain , subdomains.


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -