When running .Net Core Web API in local environment and Angular 5, XSRF token response cookies is getting generated but when deploy to production server, response cookies are not generated.
I have implemented CORS policy , web api and angular app are running in different domain and port and everything is working fine in dev environment but when deploy to production environment response cookies are not getting created.
I am using below code in Startup.cs
- app.Use(async (context, next) =>
- {
- string path1 = context.Request.Path.Value;
- if (path1 != null && path1.Contains("menu"))
- {
-
- var tokens = antiforgery.GetAndStoreTokens(context);
- context.Response.Cookies.Append("XSRF-TOKEN",
- tokens.RequestToken, new CookieOptions()
- {
- Path = "/",
- HttpOnly = false,
- Expires = DateTime.Now.AddMonths(1),
- }
- );
- }
- await next();
- });
Please help me. Its urgent and not able to figure out what I am doing wrong.
I am running application using angular cli - ng serve and in production environment I am using IIS 10 and windows 2016 server.