【问题标题】:passing header data in .NET and IIS在 .NET 和 IIS 中传递标头数据
【发布时间】:2014-03-21 01:36:10
【问题描述】:

我现有的代码通过 .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");
}

.htaccess

RewriteEngine on


RewriteRule ^(.*)/(.*)/(.*)$ videoSecure.php?h=$1&t=$2&v=$3

RewriteRule ^$ - [F]
RewriteRule ^[^/]+\.(flv|mp4)$ - [F]

它的作用是混淆和保护视频文件,使其不会直接从服务器下载,但仍允许流式传输。

我试图了解是否可以在 IIS6/7 + .NET MVC4 中实现类似的功能

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

【问题讨论】:

    标签: php asp.net .htaccess asp.net-mvc-4 iis


    【解决方案1】:

    你可以使用这样的东西。

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

    【讨论】:

      猜你喜欢
      • 2022-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-26
      • 2018-10-16
      • 1970-01-01
      • 2021-01-31
      • 1970-01-01
      相关资源
      最近更新 更多