Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/264.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
c#ASP.NET新手重定向问题_C#_Asp.net - Fatal编程技术网

c#ASP.NET新手重定向问题

c#ASP.NET新手重定向问题,c#,asp.net,C#,Asp.net,嘿,我正在努力让它工作,但我不是一个c#程序员。我用这个代码来告诉你我想做什么。但它当然不起作用。错误:CS1519:无效令牌 <%@ Page Language="c#" AutoEventWireup="true" %> <script language="C#" runat="server"> if(Request.ServerVariables["HTTP_HOST"] === "this-domain.com"){ Response.Re

嘿,我正在努力让它工作,但我不是一个c#程序员。我用这个代码来告诉你我想做什么。但它当然不起作用。错误:CS1519:无效令牌

<%@ Page Language="c#" AutoEventWireup="true" %>
<script language="C#" runat="server">
    if(Request.ServerVariables["HTTP_HOST"] === "this-domain.com"){
        Response.Redirect("http://other-domain.com", true);
    }
</script>

if(Request.ServerVariables[“HTTP_HOST”]=“this domain.com”){
响应。重定向(“http://other-domain.com“,对);
}

Microsoft.NET Framework版本:2.0.50727.3603;ASP.NET版本:2.0.50727.3601尝试将===更改为==

Request.ServerVariables["HTTP_HOST"] === "this-domain.com"
应该是

Request.ServerVariables["HTTP_HOST"] == "this-domain.com"

您需要将整个语句封装在蜂螫中

您需要将
==
更改为
=

===不需要,==就足够了

移除 脚本标签。 并使用Scriptlets


Edited发现了其他遗漏的内容
<%

  if(Request.ServerVariables["HTTP_HOST"] == "this-domain.com"){
        Response.Redirect("http://other-domain.com", true);
    }
 %>