【发布时间】:2015-10-01 04:21:32
【问题描述】:
我正在使用下面的函数
[Server.Transfer(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>
请指导我
【问题讨论】:
-
分享你到目前为止所做的代码。
-
想想如果你买了几本书从头开始会更容易。
-
@Phill 检查代码
-
@Almelyan - 代码似乎正确,它应该可以工作,尝试在页面上放置一个按钮,并在点击事件时使用相同的代码行进行传输。
-
有类似 Content-Type 的东西吗?您可以指定重定向内容是 HTML 吗?我的意思是在服务器端代码中,而不是在 html 元标记中。