在Page_Load或OnInit上加载html文件

时间:2014-08-09 19:58:16

标签: c# asp.net .net

我正在尝试加载一个html文件" en_index.html"在Page_Load。但我得到以下错误:

错误:

Failed to load resource: the server responded with a status of 500 (Internal Server Error) http://example.org/langs.js
Failed to load resource: the server responded with a status of 500 (Internal Server Error) http://example.org/provider/mainstyle.css
Failed to load resource: the server responded with a status of 500 (Internal Server Error) http://example.org/css/ltrstyle.css
Failed to load resource: the server responded with a status of 500 (Internal Server Error) http://example.org/provider/main.js

Default.aspx的

protected void Page_Load(object sender, EventArgs e)
{
   try
   {
      if (!Page.IsPostBack)
      {
          Response.WriteFile("en_index.html");
      }
   }
   catch (Exception ex)
   {

   }
}

en_index.html

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>en_index</title>
    <meta name="description" content="Here comes project description." />
    <script type="text/javascript">
        currMode = "advanced"; lang = "en"; 
    </script>
    <script src="langs.js" type="text/javascript"></script>
    <script src="provider/main.js" type="text/javascript"></script>
    <link href="provider/mainstyle.css" rel="stylesheet" type="text/css" />
    <link href="css/ltrstyle.css" rel="stylesheet" type="text/css" />
</head>
<body>
...
</body>
</html>

html文件没有问题,因为我单独运行它时工作正常。但是当我运行Default.aspx时却没有。有什么建议/想法吗?我应该如何实现它?

<小时/> 我也在页面加载时尝试过:

Page.ClientScript.RegisterClientScriptInclude("File1", HttpContext.Current.Server.MapPath("langs.js"));
Page.ClientScript.RegisterClientScriptInclude("File2", HttpContext.Current.Server.MapPath("/provider/main.js"));

1 个答案:

答案 0 :(得分:0)

终于找到了问题。问题在于web.config文件中的以下标记。但是,我不知道为什么GoDaddy不接受它。不过,它现在有效!

<staticContent>
  <mimeMap fileExtension=".otf" mimeType="application/font-sfnt" />
</staticContent>