2013-04-02 3 views
1

나는 asp.net에 초보자입니다. 나는 비디오 http://localhost/video/file.mp4의 URL을 가지고 있지만, URL에 대한 시간 제한을 만들기 위해 http://localhost/34567fghft/file.mp4과 같은 URL을 제공하고 싶습니다. 내 질문에 대한 해결책이 있습니까? 내 영어에 대한 답장을 보내 주셔서 감사합니다.동영상의 URL 다시 작성

답변

0

Global.asaxApplication_BeginRequest에서 요청 된 경로를 얻으려면 분할하고, 만료되었는지 확인하고, 문자열을 조작하고 그 에테르 오류 페이지에 에테르 실제 경로로 다시 작성 :

protected void Application_BeginRequest(Object sender, EventArgs e) 
{  
    string cTheFile = HttpContext.Current.Request.Path; 

    if (cTheFile.EndsWith("/file.mp4", StringComparison.InvariantCultureIgnoreCase)) 
    { 
     // manipulate your string to see if is expired... 
     string[] keys = HttpContext.Current.Request.Path.Split('/'); 

     // get the 34567fghft part 
     if (IfExpired(keys[keys.Length - 1])) 
     { 
      HttpContext.Current.Response.Redirect("ExpiredMessage.aspx", true); 
      return ; 
     } 
     else 
     { 
      HttpContext.Current.RewritePath("http://localhost/video/file.mp4", false); 
     } 
    } 
} 

이 코드는 어떻게하는지에 대한 아이디어입니다. 더 나은 문자열 조작과 오류 검사가 필요합니다.

+0

감사합니다.이 방법을 사용해 보았지만 나에게 도움이되지 않습니다. 정적 파일 요청은 Application_BeginRequest를 통과하지 못하므로 mp4 요청을 처리 할 수 ​​없습니다. 나는 클래스를 써서 IHttpHandler를 상속 받아 mp4 요청을 받고 RewritePath를 실제 URL로 가져 왔지만 Player는 재생할 수 없습니다. -s – DzungHoang

+0

@dugchie Ether이 파일을 제공하는 핸들러를 작성하거나 IIS를 설정하면이 정적 파일이 다음과 같이 전달됩니다. asp.net – Aristos