高分求ASP代码[7行]转化成C#代码
<%Dim strAcceptLanguage
strAcceptLanguage = Request.ServerVariables("HTTP_ACCEPT_LANGUAGE")
Select Case strAcceptLanguage
Case "zh-cn"
Response.Redirect "/Error.html"
Case Else
End Select
%>
我想把它放在全站都包含的头文件里,实现浏览器语言的判定并重新定向,头文件为:top.ascx
代码为:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="top.ascx.cs" Inherits="xxx.top" %>
<table width="970" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><table width="850" height="80" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="260"> <div align="right"><img src="images/logo.gif" width="247" height="40"></div></td>
<td width="371" valign="bottom"> </td>
<td> </td>
<td width="110" class="t1"> <div align="center">
<table width="120" border="0" cellpadding="0" cellspacing="0" class="t1">
<tr>
<td height="40"> </td>
</tr>
<tr>
<td><div align="center"><a target=_top href=javascript:window.external.AddFavorite('http://www.xxx.com','xxx')>Favorites</a></div></td>
</tr>
</table>
</div></td>
</tr>
</table></td>
</tr>
</table>
<table width="936" height="47" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="166"><img src="images/dh_l.gif" width="166" height="47"></td>
<td background="images/dh_bg.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="center"><a href="default.aspx" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image18','','images/d1_2.gif',1)"><img src="images/d1_1.gif" name="Image18" width="47" height="47" border="0"></a></div></td>
<td><div align="center"><a href="aboutus.aspx" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image19','','images/d2_2.gif',1)"><img src="images/d2_1.gif" name="Image19" width="69" height="47" border="0"></a></div></td>
<td><div align="center"><a href="quality.aspx" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image20','','images/d3_2.gif',1)"><img src="images/d3_1.gif" name="Image20" width="58" height="47" border="0"></a></div></td>
<td><div align="center"><a href="product.aspx" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image21','','images/d4_2.gif',1)"><img src="images/d4_1.gif" name="Image21" width="64" height="47" border="0"></a></div></td>
<td><div align="center"><a href="video.aspx" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image22','','images/d5_2.gif',1)"><img src="images/d5_1.gif" name="Image22" width="114" height="47" border="0"></a></div></td>
<td><div align="center"><a href="service.aspx" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image24','','images/d6_2.gif',1)"><img src="images/d6_1.gif" name="Image24" width="66" height="47" border="0"></a></div></td>
<td><div align="center"><a href="contactus.aspx" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image25','','images/d7_2.gif',1)"><img src="images/d7_1.gif" name="Image25" width="86" height="47" border="0"></a></div></td>
</tr>
</table></td>
<td width="168"><img src="images/dh_r.gif" width="168" height="47"></td>
</tr>
</table> --------------------编程问答-------------------- 帮顶! --------------------编程问答-------------------- 放在Gloab.aspx的session_start 中 --------------------编程问答-------------------- 用母板试试看。 --------------------编程问答-------------------- 最好能把成品的代码写出来 哥们对c#.net一点都不熟... --------------------编程问答-------------------- 你应该把你的ASP代码加上注释。每行都是做什么别人好给你写代码 --------------------编程问答--------------------
--------------------编程问答-------------------- 加到
string strAcceptLanguage=null;
strAcceptLanguage=this.Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"];
if(strAcceptLanguage.Equals("zh-cn"))
{
this.Response.Redirect("~/Error.html");
}
Page_Load里 --------------------编程问答-------------------- 这里可能是html中meta属性,用C#怎么取,还不知道。查查吧。至于用vbscript还是C#是小事。 --------------------编程问答-------------------- Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"];
似乎是这样。 --------------------编程问答--------------------
这个加到top.ascx 根本不能用
怎么用vbscript?写出代码来哈 谢谢~我是菜鸟
寒,就这几行代码一眼就能看出来作用吧
<%
Dim strAcceptLanguage
strAcceptLanguage = Request.ServerVariables("HTTP_ACCEPT_LANGUAGE") //取请求浏览器的语言信息
Select Case strAcceptLanguage
Case "zh-cn" //如果是简体中文页
Response.Redirect "/Error.html" //则重定向到错误页
Case Else
End Select
%> --------------------编程问答-------------------- ....就没人会么?
补充:.NET技术 , ASP.NET