【发布时间】:2020-12-20 06:36:10
【问题描述】:
我一直试图找出我的代码有什么问题。我知道它在服务器端 Blazor 上运行,但为什么不使用 Assembly 类型?
我的代码是这样的。
CookieContainer cookies = new CookieContainer();
HttpClientHandler handler = new HttpClientHandler();
handler.CookieContainer = cookies;
HttpClient authClient = new HttpClient(handler);
var requestMessage = new HttpRequestMessage(HttpMethod.Post, theUrl) { Content = new FormUrlEncodedContent(dict) };
var responseCookies = cookies.GetCookies(theUrl).Cast<Cookie>();
我在VS中按F10逐行调试代码,当它点击handler.CookieContainer = cookies;时会抛出一个异常,上面写着Property Container is not supported.那么我怎样才能检索cookie?
只是为了给您提供上下文,Web API 不是 Restful,它是一项古老的技术,因此它只是基于简单的 http POST 请求并返回 xml 和一些 cookie 以确保安全。
【问题讨论】:
标签: c# cookies blazor-client-side blazor-webassembly