设置Cookies chrome和safari不适用于webapi和angular

时间:2018-11-27 13:08:46

标签: google-chrome asp.net-mvc-4 cookies safari asp.net-web-api2

我将asp.net WebApi .Net和Angular2 +用于我的网站,对于某些用户(不是所有人),chrome和safari不会设置cookie,我解释说:当用户在首页上正确登录时,我会设置带有响应的cookie并且他被重定向到站点Web并调用api,但是api响应了一个未解密的错误,因为当我要验证cookie时,请求中的cookie为null,因此他被重定向到主页

这里是我的代码,用于使用asp.Net设置和获取Cookie:import numpy as np import matplotlib.pyplot as plt from scipy.optimize import curve_fit x = np.linspace(0,10,60) w = [1,2,3,4,5] a = [1,4,2,3,0.1] x0 = [0,1,0,1,0.5] y = np.sum(a_i * np.sin(w_i * x - x0_i) for w_i, a_i, x0_i in zip(w,a, x0)) #base_data yr = y + np.random.normal(0,0.5, size=x.size) #noisy data def func(x, *args): """ function of the form lambda x, amp1, phase1, amp2, phase2....""" return np.sum(a_i * np.sin(w_i * (x-x0)) for w_i, a_i, x0 in zip(w,args[::2], args[1::2])) ubounds = np.zeros(len(w) * 2) ubounds[::2] = 10 #setting amp max value to 10 (arbitrary) ubounds[1::2] = np.asarray(w) * 2 * np.pi p0 = [0] * 10 # note p0 size popt, pcov = curve_fit(func, x, yr, p0, bounds=(0, ubounds)) amps, phases = popt[::2], popt[1::2] plt.plot(x,func(x, *popt)) plt.plot(x,yr, 'go') HttpContext.Current.Response.Cookies.Add(new HttpCookie(CookieName, token));

,我在从angular的电话中拥有withcredential属性。

我不知道为什么此过程仅对某些用户有效,而不对所有人有效?有没有我忘记的配置?

0 个答案:

没有答案