2017-09-13 13 views
0

HTML 사이트를 ASP.Net 4.0 웹 응용 프로그램으로 마이그레이션하고 있습니다. 다른 사람이 기존 HTML 페이지 URL을 입력하면 해당 ASP 페이지로 리디렉션하고 싶습니다.HTML 응용 프로그램을 ASP.NET 4.0으로 마이그레이션하는 동안 IIS 7에서 Global.asax의 응용 프로그램 오류가 발생하지 않습니다.

나는 이미 아래 제안을 시도했지만 아무 것도 해결되지 않았습니다. 하지의 Global.asax 페이지에함으로써 Application_Error 방법에 따라 코드 아래

enter code here 
<customErrors mode="On"> 
    <error statusCode="404" redirect="~/Error.aspx" /> 
</customErrors> 
enter code here 
  • 일 포함 -

    1. 은 Web.config의 일부 ASP 페이지로 리디렉션 사용자 지정 오류 태그를 포함. - 그것은

      enter code here 
      
      void Application_Error(object sender, EventArgs e) 
          { 
           // Code that runs when an unhandled error occurs 
           string fullOrginalpath = Request.Url.ToString(); 
           string strPathExtn = 
            Request.CurrentExecutionFilePathExtension.ToString(); 
           if (fullOrginalpath.Contains(".html")) 
           { 
            Server.ClearError(); 
            Response.Clear(); 
            fullOrginalpath = fullOrginalpath.Replace(".html", ".aspx"); 
            Response.Redirect(fullOrginalpath); 
           }   
          } 
      enter code here 
      
    2. 이 web.cofig에서의 httpErrors 태그를 가진 시도가 발생하지 않습니다 - 그것은 500 내부 오류가 발생합니다.

  • 답변