【问题标题】:FLV video not running in browser with no error in ASP.NetFLV 视频未在浏览器中运行,在 ASP.Net 中没有错误
【发布时间】:2012-10-08 11:55:40
【问题描述】:

我正在尝试将当前在 Windows Server 2003 32 位和 IIS6 上运行的 ASP.NET 应用程序部署到运行 Windows Server 2008 R2 和 IIS7 的新服务器上。 我的应用程序使用 ASP.NET 4.0 版,并且在 2003 机器上运行良好。

我的问题是:

我已经部署了应用程序,它工作正常,只是 .flv 视频没有在浏览器中播放

我已添加所有必需的 mime 设置,但仍然没有成功

当我尝试运行视频时,我没有收到任何错误,只是一个空白屏幕显示没有视频。

相同的配置在以前的机器上运行,新的服务器也能够在从较早的机器上运行时播放视频。

如果您有任何解决方案,请帮助我。


我刚刚发现在我尝试运行视频时会记录一个事件错误条目。如下:

    Event code: 3005 
    Event message: An unhandled exception has occurred.
    Event time: 10/9/2012 1:07:14 PM 
    Event time (UTC): 10/9/2012 8:07:14 PM 
    Event ID: 09303bdb94d64235a5ab118955416895 
    Event sequence: 12 
    Event occurrence: 1 
    Event detail code: 0 

    Application information: 
        Application domain: /LM/W3SVC/1/ROOT/BYPL-1-129942868205521131 
        Trust level: Full 
        Application Virtual Path: /BYPL 
        Application Path: F:\BYPL_Simulator_26_Sept_2012\ 
        Machine name: BYPL-APP-SERVER 

    Process information: 
        Process ID: 2536 
        Process name: w3wp.exe 
        Account name: BYPL-APP-SERVER\Administrator 

    Exception information: 
        Exception type: HttpException 
        Exception message: Could not load type 'FLVStreaming'.
        at System.Web.Compilation.BuildManager.GetType(String typeName, Boolean  throwOnError, Boolean ignoreCase)
        at System.Web.Configuration.HandlerFactoryCache.GetTypeWithAssert(String type)
        at System.Web.Configuration.HandlerFactoryCache.GetHandlerType(String type)
        at System.Web.Configuration.HandlerFactoryCache..ctor(String type)
        at System.Web.HttpApplication.GetFactory(String type)
        at           System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
        at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

    Request information: 
        Request URL: http://localhost/BYPL/Administrator/MeterManagement/Installation/video/634655271233125000.flv
        Request path: /BYPL/Administrator/MeterManagement/Installation/video/634655271233125000.flv 
        User host address: 127.0.0.1 
        User: bypl 
        Is authenticated: True 
        Authentication Type: Forms 
        Thread account name: BYPL-APP-SERVER\Administrator 

        Thread information: 
        Thread ID: 5 
        Thread account name: BYPL-APP-SERVER\Administrator 
        Is impersonating: False 
        Stack trace:    at System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)
        at System.Web.Configuration.HandlerFactoryCache.GetTypeWithAssert(String type)
        at System.Web.Configuration.HandlerFactoryCache.GetHandlerType(String type)
        at System.Web.Configuration.HandlerFactoryCache..ctor(String type)
        at System.Web.HttpApplication.GetFactory(String type)
        at System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
        at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

【问题讨论】:

    标签: asp.net iis-7 iis-7.5 windows-server-2008-r2


    【解决方案1】:

    我自己找到了答案。

    我在 app_code 文件夹中添加了一个名为 FLVStreaming.cs 的文件,然后重新发布了应用程序,该文件包含以下代码:

    using System.Web;
    public class FLVStreaming : IHttpHandler
    {   // FLV header
    public FLVStreaming()
    {}
    public void ProcessRequest(HttpContext context)
    { try{
            int pos;
            int length;
            // Check start parameter if present
            string filename = Path.GetFileName(context.Request.FilePath);
            using (FileStream fs = new   FileStream(context.Server.MapPath(filename), FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                string qs = context.Request.Params["start"];
                if (string.IsNullOrEmpty(qs))
                {
                    pos = 0;
                    length = Convert.ToInt32(fs.Length);
                }
                else
                {
                    pos = Convert.ToInt32(qs);
                    length = Convert.ToInt32(fs.Length - pos) + _flvheader.Length;
                }
                // Add HTTP header stuff: cache, content type and length        
                context.Response.Cache.SetCacheability(HttpCacheability.Public);
                context.Response.Cache.SetLastModified(DateTime.Now);
                context.Response.AppendHeader("Content-Type", "video/x-flv");
                context.Response.AppendHeader("Content-Length", length.ToString());
                // Append FLV header when sending partial file
                if (pos > 0)
                {
                    context.Response.OutputStream.Write(_flvheader, 0, _flvheader.Length);
                    fs.Position = pos;
                }
                // Read buffer and write stream to the response stream
                const int buffersize = 16384;
                byte[] buffer = new byte[buffersize];
                int count = fs.Read(buffer, 0, buffersize);
                while (count > 0)
                {
                    if (context.Response.IsClientConnected)
                    {
                        context.Response.OutputStream.Write(buffer, 0, count);
                        count = fs.Read(buffer, 0, buffersize);
                    }
                    else
                    {
                        count = -1;
                    }
                }
            }
        }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine(ex.ToString());
        }
    }
    public bool IsReusable
    {   get { return true; }
    }
    private static byte[] HexToByte(string hexString)
    { 
        byte[] returnBytes = new byte[hexString.Length / 2];
        for (int i = 0; i < returnBytes.Length; i++)
            returnBytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2), 16);
        return returnBytes;
    }
    }
    

    此文件似乎已转换为 .ddl 文件,并且此 dll 文件版本与机器架构不匹配。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-21
      • 2018-07-18
      • 2012-11-15
      • 2022-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-20
      相关资源
      最近更新 更多