从来不用WINDOWS空间的我最近为客户在godaddy购买了windows共享空间,不幸的是运行ASP.NET网页出现火星文,但是从ACCESS数据库读取出来的都是正确的。同时,此网页在中文操作系统上显示完全正常。
也曾经在百度和谷歌上搜索过godaddy上.NET火星文问题,但是解决的都是数据库乱码显示问号的问题,而我的这个错误不是由于数据库引起的,从数据库里读取出来的数据完全能正常显示。求解决方法。
错误网页:http://www.air-cs.com/airline/airline.aspxairline.aspx的全部代码:<%@ Page Language="C#" ContentType="text/html"%>
<%@ Import Namespace="System.Data" %>
<%@ Import NameSpace="System.Data.OleDb" %>
<script runat="server">
void mGetRandContent(){ //随机获得10个,供首页显示。string strDb=Server.MapPath("dbbackup/flight.mdb");//数据字典位置,如果要防止下载,把.mdb后缀改其它后,在这里修改
//Response.Write(strDb);
string strAuth="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=";
OleDbConnection db=new OleDbConnection(strAuth+strDb);//strKey=Regex.Replace(strKey,"[=\\s\"\'!,.。,~@#¥%……&*(){}`+《》<>?/]","",RegexOptions.IgnoreCase).Trim();//防止SQL注入
int iDate=System.DateTime.Now.Day;
string strSql="SELECT TOP 3 * FROM louhome ORDER BY rnd("+iDate.ToString()+"-id) DESC "; 
OleDbCommand cmd=new OleDbCommand(strSql,db);
try{
db.Open();dl.DataSource=cmd.ExecuteReader();
dl.DataBind();
db.Close();cmd.Dispose();
db.Dispose();labCount.Text=dl.Items.Count.ToString();
if(dl.Items.Count==0)
labError.Text="没有找到任何相关数据,请缩短输入再查询!";
else labError.Text="";
}
catch(Exception ee){
labError.Text=ee.ToString();
}
}void mGetContent(string strKey){string strDb=Server.MapPath("dbbackup/flight.mdb");//数据字典位置,如果要防止下载,把.mdb后缀改其它后,在这里修改
//Response.Write(strDb);
string strAuth="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=";
OleDbConnection db=new OleDbConnection(strAuth+strDb);strKey=Regex.Replace(strKey,"[=\\s\"\'!,.。,~@#¥%……&*(){}`+?/]","",RegexOptions.IgnoreCase).Trim();//防止SQL注入string strSql="SELECT TOP 1990 Name,Content FROM louhome WHERE Name LIKE '%"+strKey+"%'"; 
OleDbCommand cmd=new OleDbCommand(strSql,db);
try{
db.Open();dl.DataSource=cmd.ExecuteReader();
dl.DataBind();db.Close();cmd.Dispose();
db.Dispose();
labCount.Text=dl.Items.Count.ToString();
if(dl.Items.Count==0)
labError.Text="没有找到任何相关数据,请缩短输入再查询!";
else labError.Text="";
}
catch(Exception ee){
labError.Text=ee.ToString();
}
}string strTitle(string strInput){
string strResult=strInput;string strRex;
if(tbKey.Text.Trim()=="")
strRex="DDXXTX";
else strRex=tbKey.Text.Trim();strResult=strResult.Replace(strRex,"<FONT STYLE='background:yellow;color:red'>"+strRex+"</FONT>");
//strResult=Regex.Replace(strResult,strRex,"<FONT STYLE='background:yellow;color:red'>"+strRex+"</FONT>", RegexOptions.IgnoreCase);return strResult;
}
void mSearch(object sender,EventArgs e){
labTopMsg.Visible=false;
mGetContent(tbKey.Text.Trim());}
void Page_Load(){
if(!Page.IsPostBack){
mGetRandContent();}
}
</script>
<!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; charsetgb2312" />
<title>中国民航航班大查询</title>
</head>
<body>
<!--#include Virtual="/Module/Includes/Top1.asp" -->
<form runat="server" style="width:90%; margin:0px auto;">
  <img src="images/logo.gif" alt="机票网" border="0"/> <br />
  <asp:Label ID="labError" runat="server" Font-Size="8pt" ForeColor="#999999"/>
  <br />
  &nbsp;
  关键字
  <asp:TextBox ID="tbKey" runat="server" Width="160px" AutoPostBack="false" MaxLength="8"/>
  <asp:RequiredFieldValidator ID="rfv" runat="server" ControlToValidate="tbKey" ErrorMessage="*" Display="Dynamic"/>  
  <asp:Button ID="btn" runat="server" OnClick="mSearch" Text="查看"/>
  <font color="#CCCCCC">如果显示结果不正确,请输入机场或航班代码作为关键字</font>
  <br />
  <br style="height:8px"/>  <div style="background:#75CBFF; color:#666666; width:30%; height:20px; padding-top:4px; float:left; text-align:right">共有
      <asp:Label ID="labCount" runat="server" Text="0" ForeColor="#FF0000"/>  
    个相关结果&nbsp;&nbsp;</div>
  <br style="height:8px"/><br />
  <asp:Label ID="labTopMsg" runat="server" Font-Bold="true" Font-Size="15px" ForeColor="#FF0000" Visible="true" Text="【每日一学】"/>
  <br style="height:8px"/>
  <asp:DataList ID="dl" runat="server" Width="98%">
    <itemtemplate>
      <div style="background:#016392; color:#FFFFFF; width:80px; clear:both;"><i>&middot;结果 <%#(Container.ItemIndex+1).ToString()%></i></div>
      <div style="width:99%; border:1px solid #016392;">
        <div style="background:#E2E3D7; font-weight:bold; padding:2px;">
          <asp:Label ID="labName" runat="server" Text=<%#(DataBinder.Eval(Container.DataItem,"Name").ToString()) %> />
        </div>
        <div style=" padding:10px;">
  <asp:Label id="labContent2" runat="server" Text=<%#"<font style='color:#0000ff;'>"+strTitle(DataBinder.Eval(Container.DataItem,"Content").ToString().Replace("{BR}","<br>").Replace("#","&"))+"</font>"%> />   <br style="height:4px"/> <br style="height:6px"/>
        </div>
      </div>
<br/>
    </itemtemplate>
  </asp:DataList>
  <!--#include Virtual="/Module/Includes/Bottom.asp" -->
</form></body>
</html>