本帖最后由 zsdtylj 于 2022-2-26 17:18 编辑
其实很简单.我自己就用了好久了.自己写一个服务端插件.去获取对应的cookie.这个关键的代码.可以参考下.直接返回获取的cookie- public void login()
- {
- var form = Context.Request.ReadFormAsync().Result;
- var urladd = form["URL"];
-
- HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urladd);
-
- try
- {
- HttpWebResponse response = (HttpWebResponse)(request.GetResponse());
- string cc = response.GetResponseHeader("Set-Cookie");
- this.Context.Response.WriteAsync(cc);
- }
- catch (WebException ex)
- {
- var response = (HttpWebResponse)ex.Response;
- string cc = response.GetResponseHeader("Set-Cookie");
-
- string[] machineStrings = cc.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
- string[] st1 = machineStrings.Where(s => s.StartsWith("sessionCookie")).ToArray();
- string[] st2 = machineStrings.Where(s => s.StartsWith("_ati")).ToArray();
- this.Context.Response.WriteAsync(st1[0]);
- }
复制代码
|