简体   繁体   中英

c# ASP.NET newb redirect question

Hey I'm trying to get this working but I am not ac# programmer. i got this code to display you what i would like to do. but of cause its not working. Error: CS1519: Invalid Token...

<%@ 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>

Microsoft .NET Framework-Version:2.0.50727.3603; ASP.NET-Version:2.0.50727.3601

尝试将===更改为==

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

Should be

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

And you need to enclose the whole statement in bee stings <% %>

您需要将===更改为==

=== is not needed,== is enough.

and remove script tag. and use Scriptlets ie <% %>

<%

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM