I'm creating a Blazor web application with .Net Core and trying to save the token in the cookie. However I get the error:
The name Response does not exist in the currect context
In all the examples that I have seen people do not face this problem. What do I have to do?
@functions {
async Task Submit()
{
using (var client = new HttpClient())
{
User user = new User(state.user.Username, state.user.Password);
var response = await client.PostAsJsonAsync("api/adimin/token", user);
var token = await response.Content.ReadAsAsync<string>();
var option = new CookieOptions();
option.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Append(setting, token, option);
}
}
}
This worked well to me:-
Replace Response with HttpContext.Current.Response
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With