Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html ASP.net:为什么页面显示为文本?_Html_Asp.net_.net_Vb.net - Fatal编程技术网

Html ASP.net:为什么页面显示为文本?

Html ASP.net:为什么页面显示为文本?,html,asp.net,.net,vb.net,Html,Asp.net,.net,Vb.net,我正在使用下面的函数 [服务器传输(url)] 在重定向到html页面的代码中 但为什么html页面在浏览器中显示为文本 在Global.asax文件中编码: Protected Sub Application_BeginRequest(ByVal sender As Object, ByVal e As System.EventArgs) '' Accpeted Firefox browser only : If Not GlobelApp.ValidBrowser(Request

我正在使用下面的函数

[服务器传输(url)]

在重定向到html页面的代码中

但为什么html页面在浏览器中显示为文本

在Global.asax文件中编码:

Protected Sub Application_BeginRequest(ByVal sender As Object, ByVal e As System.EventArgs)
   '' Accpeted Firefox browser only :
   If Not GlobelApp.ValidBrowser(Request.Browser) Then
       Server.Transfer("browser.html")
       Exit Sub
    End If
End Sub
Html页面代码browser.Html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
        <title>Update Browser</title>
        <style type="text/css">
            @font-face {
              font-family: 'Droid Sans Arabic';
              src: url('fonts/droid-sans-arabic.ttf') format('truetype');
            }
            * { font-family:'Droid Sans Arabic', 'Segoe UI'; font-weight:lighter; color:#444; direction:rtl; }
            h1 {  font-weight:lighter; text-align:center; }
            a { color:#3276B1; text-align:center; }
            p { line-height: 33px; text-align:center; }
        </style>
    </head>
    <body>
        <div style="width:550px; margin:120px auto 10px;">
            <img src="img/firefox.png" style="width:180px;margin:0px auto; display:block;" />
            <h1 style="padding-top:15px;">تحديث المتصفح</h1>
            <p>
                لكي يعمل النظام لديك عليك تحميل متصفح الفايرفوكس Firefox بأحدث إصدار <br />
                <a href="https://www.mozilla.org/en-US/firefox/new/">تحميل المتصفح الفايرفوكس Firefox</a>
            </p>
        </div>
    </body>
</html>

更新浏览器
@字体{
字体系列:“Droid无阿拉伯语”;
src:url('font/droidsans-arabic.ttf')格式('truetype');
}
*{字体系列:'Droid Sans Arabic','Segoe UI';字体重量:较轻;颜色:#444;方向:rtl;}
h1{字体重量:较轻;文本对齐:居中;}
a{color:#3276B1;文本对齐:居中;}
p{行高:33px;文本对齐:居中;}
تحديث المتصفح

本1603月月日日,在本1603月月日日日日日日,在本1603月日日日日日日方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方


当服务器响应时,请指导我

我们必须通过在响应标题中放置标题内容类型来指定响应内容为HTML

在普通ASP页面中是默认的,但是当从Global.asax重定向时,我认为响应中没有标题

因此,不要使用
Server.Transfer
函数,而是使用
Server.TransferRequest(路径、保存表单、方法、标题)
,这样我们就可以放置内容类型标题

这里的代码工作正常

Dim headers As New NameValueCollection
headers.Add("Content-Type", "text/html")
Server.TransferRequest("browser.html", False, "GET", headers)

感谢@rajeshmpanchal@Uğur Aldanmaz的帮助^ ^ ^ ^ ^

分享你迄今为止所做的代码。想一想,如果你买了几本书,从头开始会更容易些。@Phill查看code@Almelyan-代码似乎正确,应该可以工作,尝试在页面上放置一个按钮,然后单击事件,使用相同的代码行进行传输。是否有类似的内容类型?能否指定重定向内容为HTML?我的意思是在服务器端代码,而不是在html元标记中。