Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在.NET和IIS中传递头数据_Php_Asp.net_.htaccess_Asp.net Mvc 4_Iis - Fatal编程技术网

Php 在.NET和IIS中传递头数据

Php 在.NET和IIS中传递头数据,php,asp.net,.htaccess,asp.net-mvc-4,iis,Php,Asp.net,.htaccess,Asp.net Mvc 4,Iis,我有一个现有的代码,它通过.htaccess将php中视频文件的信息传递给视频播放器。我试图理解这样的东西是如何在IIS和.NET中复制的 php脚本: $hash = $_GET['h']; $streamname = $_GET['v']; $timestamp = $_GET['t']; $current = time(); $token = 'sn983pjcnhupclavsnda'; $checkhash = md5($token . '/' . $streamname . $tim

我有一个现有的代码,它通过.htaccess将php中视频文件的信息传递给视频播放器。我试图理解这样的东西是如何在IIS和.NET中复制的

php脚本:

$hash = $_GET['h'];
$streamname = $_GET['v'];
$timestamp = $_GET['t'];
$current = time();
$token = 'sn983pjcnhupclavsnda';
$checkhash = md5($token . '/' . $streamname . $timestamp);

if (($current - $timestamp) <= 2 && ($checkhash == $hash)) {
  $fsize = filesize($streamname);
  header('Content-Disposition: attachment; filename="' . $streamname . '"');
  if (strrchr($streamname, '.') == '.mp4') {
    header('Content-Type: video/mp4');
  } else {
    header('Content-Type: video/x-flv');
  }
  header('Content-Length: ' . $fsize);
  session_cache_limiter('nocache');
  header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
  header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
  header('Pragma: no-cache');
  $file = fopen($streamname, 'rb');
  print(fread($file, $fsize));
  fclose($file);
  exit;
} else {
  header("location:.$player_id");
}
这样做的目的是混淆和保护视频文件,使其不会直接从服务器下载,但仍然允许其流式传输

我试图了解我是否可以在IIS6/7+中实现这样的功能.NETMVC4


或者,我是否能够保留php并通过IIS执行它,尽管大多数站点都使用.NET环境,这会产生任何问题?

您可以使用类似的方法

Response.AppendHeader("Content-Type", "video/mp4");
Response.AppendHeader("Content-Type", "video/mp4");