1.跳转
[HttpGet]
public HttpResponseMessage LinkTo()
{
HttpResponseMessage resp = new HttpResponseMessage(HttpStatusCode.Moved);
resp.Headers.Location = new Uri("http://x.com");
return resp;
}
2.输出script
[HttpGet]
public HttpResponseMessage ResponseScript()
{
HttpResponseMessage resp = new HttpResponseMessage();
resp.Content = new StringContent("<script>alert('xxx');window.location.href="about:blank"; window.close();</script>", System.Text.Encoding.Default); //红色标注关闭chrome当前页,直接用window.close无作用
resp.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("text/html");
return resp;
}
From:https://www.cnblogs.com/xuejianxiyang/p/10478091.html