If must end with a matching End It

W

William

Does anyone know what is causing the error below. The following scipt runs
in .asp but not .aspx??? Please help.

Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30081: 'If' must end with a matching 'End If'.

<%
'Set Session ID for each visitor to the site.
if Request.Cookies("SID") = "" then
if Session("SID") = "" then
Function CreateGUID()
Dim oTypeLib, sGUID
set oTypeLib = Server.CreateObject("Scriptlet.Typelib")
sGUID = oTypeLib.GUID
sGUID = LCase(sGUID)
sGUID = Mid(sGUID, 1, Len(sGUID) - 2)
Set oTypeLib = Nothing
CreateGUID = sGUID
End Function
Response.Cookies("SID")=CreateGUID
Response.Cookies("SID").Expires = Date + 365
Session("SID") = CreateGUID
end if
end if
if Request.Cookies("SID") <> "" then
if Session("SID") = "" then
Session("SID") = Request.Cookies("SID")
end if
end if
if Session("SID") <> "" then
if Request.Cookies("SID") = "" then
Response.Cookies("SID") = Session("SID")
Response.Cookies("SID").Expires = Date + 365
end if
end if
'Set Tracking Variables for each visitor to the site.
if LEN(session("id")) < 1 then
if LEN(Request.QueryString("id")) <> 0 then
if LEN(Request.Cookies("id")) < 1 then
Session("id") = Request.QueryString("id")
Response.Cookies("id")=Request.QueryString("id")
Response.Cookies("id").Expires = Date + 365
Session("keywords") = Request.QueryString("keywords")
Response.Cookies("keywords")=Request.QueryString("keywords")
Response.Cookies("keywords").Expires = Date + 365
Session("campaignno") = Request.QueryString("campaignno")
Response.Cookies("campaignno")=Request.QueryString("campaignno")
Response.Cookies("campaignno").Expires = Date + 365
Session("adgroup") = Request.QueryString("adgroup")
Response.Cookies("adgroup")=Request.QueryString("adgroup")
Response.Cookies("adgroup").Expires = Date + 365
end if
end if
end if
if LEN(Request.Cookies("id")) <> 0 then
Session("id") = Request.Cookies("id")
Session("keywords") = Request.Cookies("keywords")
Session("campaignno") = Request.Cookies("campaignno")
Session("adgroup") = Request.Cookies("adgroup")
end if
'Set session Referring URL, IP, Broswer Type so that it can be captured with
order.
if LEN(Session("referer")) < 1 then
Session("referer") = Request.ServerVariables("HTTP_REFERER")
Session("scriptname") = Request.ServerVariables("SCRIPT_NAME")
Session("useragent") = Request.ServerVariables("HTTP_USER_AGENT")
Session("remotehost") = Request.ServerVariables("REMOTE_HOST")
end if
%>
 
J

Jonathan Allen

Even in ASP, you really shouldn't put global code (i.e. function, sub,
class) inside an if-then block.Since I used code-behind, I don't know if it
is even allowed in ASP.Net.
 
C

Cor Ligthert

William,

When this runs in ASP, than it is in my opinion a bug that you are using.
This is in not in anyway right coding.

Just my thought,

Cor
 
N

Nick Malik [Microsoft]

I don't see the bug. Suggestion: try removing each of the IF blocks until
the code compiles correctly. The last one you removed is the offending one.
Then add it back in and remove the contents, leaving only the conditionals.
If it compiles, then the problem is in the body.

One thing to look for: are you using a double-quote from ASCII and a
double-quote from another character set?

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
 
S

Simon Verona

I would suspect that the inbedded function is confusing the compiler - try
removing it and see it compiles. If so, then engineer the function external
to the main global code (as suggested previously).

Regards
Simon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top