Click here to Skip to main content
15,886,763 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I got me a new domain name for my website and it used to be SomeOldWebsiteURL.com, now it's NewWebsite.com and the below is the HTML for the redirect page I am placing on my old server.

My whole little redirect page is the following. This HAS to be done in Classic ASP and VBScript, I have no choice there.

<%
	Dim str As String = HttpContext.Current.Request.Url.Host

	If (String.Compare(HttpContext.Current.Request.Url.Host, "SomeOldWebsiteURL.com", True) = 0) Then
		Response.Redirect("index.asp")
	End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
</head>
<html>
<body>

</body>
</html>


When I try to run this, I get an "Expected end of statement" error on the line Dim str As String. Does anybody have a suggestion as to what I might be doing wrong?

Thanks in advance!

Brian
Posted

Replace
VBScript
Dim str As String = HttpContext.Current.Request.Url.Host

with
VBScript
Dim str
str = HttpContext.Current.Request.Url.Host


BTW you actually are NOT using str in the remaining code.
 
Share this answer
 
Shouldn't it be the other way round?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
</head>
<html>
<body>

<%
	Dim str As String = HttpContext.Current.Request.Url.Host
 
	If (String.Compare(HttpContext.Current.Request.Url.Host, "SomeOldWebsiteURL.com", True) = 0) Then
		Response.Redirect("index.asp")
	End If
%> 

</body>
</html>
 
Share this answer
 
Is that an actual line break in the String.Compare call? If so, you'll need an underscore before the line break to let VB know that you'll be continuing the statement on the next line.
 
Share this answer
 
Comments
Member 11237256 10-Feb-15 4:13am    
Error : need end of statement but i can't find the solution please give some solution for the same.

Dim cmd As SqlCommand = New SqlCommand("insert into store(st_code,descr,M_code,cate)”) values ('" + TextBox2.Text + "')", con)
ekolis 17-Aug-16 10:07am    
Is this a VB error or a SQL error? You have a smart quote inside your SQL statement (after cate and before values) which doesn't belong there.

By the way, you should never insert values from a text box directly into a database; that leaves you vulnerable to SQL injection (a simple form of hacking which can be used to read, modify, or delete your data). You should always use parameterized queries: https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.parameters(v=vs.110).aspx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900