asp.net web api - Using Forms Authentication with WebAPI when the client is in a different domain? -
related question:
authentication in .net web api using mvc formsauthentication
i have client application lives outside of webapi solution's domain (right 2 different solutions on localhost - 1 on port x, other on port y). i'm attempting use forms authentication code this:
if (websecurity.login(model.username, model.password, persistcookie: true)) { var response = request.createresponse(httpstatuscode.ok, "logged in successfully"); return response; }
in postman works, using client / js application, cookie not saved, user never authenticated. see _requestverificationtoken, never .aspxauth token.
a requirement of application use forms auth setting cookies using websecurity. possible when client , server on different domains?
if there's else can provide make issue clearer, please let me know.
assuming using cors. default, cookies not enabled cors. in jquery, need set
xhrfields: { withcredentials: true }
also, server must send response header access-control-allow-credentials: true
.
Comments
Post a Comment