Ajax asp.Net MVC authroize在部分视图中发出的请求,并通过服务器追加标头
我正在尝试做以下工作,但不确定我是否以正确的方式进行。正如标题中提到的,我使用的是asp.NETMVC4Ajax asp.Net MVC authroize在部分视图中发出的请求,并通过服务器追加标头,ajax,asp.net-mvc,asp.net-mvc-partialview,authorize-attribute,Ajax,Asp.net Mvc,Asp.net Mvc Partialview,Authorize Attribute,我正在尝试做以下工作,但不确定我是否以正确的方式进行。正如标题中提到的,我使用的是asp.NETMVC4 我从一个页面向服务器发出ajax请求。ajax请求调用follow函数 public ActionResult VideoFeed() { // Create a new 'HttpWebRequest' Object to the mentioned URL. HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebReq
- 我从一个页面向服务器发出ajax请求。ajax请求调用follow函数
public ActionResult VideoFeed() { // Create a new 'HttpWebRequest' Object to the mentioned URL. HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create("http://url/cgi/image.php?type=live"); // Digest Authenticate myHttpWebRequest.Credentials = new NetworkCredential(username, password); // Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable. HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse(); // Store headers string authorization = myHttpWebRequest.Headers["Authorization"]; string host = myHttpWebRequest.Headers["Host"]; // Add header Response.AppendHeader("Authorization", authorization); Response.AppendHeader("Host", host); return PartialView("~/Views/RedLight/SystemStatus/_Video.cshtml"); }
- 在这个函数中,我试图使用HttpWebRequest执行摘要身份验证
- 这看起来很好,我能够解析头
- 然后您会注意到,我正试图将这些标题附加到发出此请求的当前页面
- 最后,我调用一个局部视图来返回当前页面。部分视图除了一个img标记外没有其他内容,该标记的src属性等于上述函数中存在的url
查德经过一番研究,我逐渐意识到我的方法行不通。相反,我需要创建一个代理方法。即,客户端调用我的服务器->我的服务器调用url->我的服务器流到客户端 我已将一个后续问题发布在- 谢谢 查德