[thelist] ASP and WML/WAP

Mike Hardaker mike at angloinfo.com
Wed Feb 7 20:22:31 CST 2001


After waffling on about the media, I felt I owed a:

<tip type="ASP, WML and response.ridirect" author="Mike Hardaker">
If you're developing WML Pages for WAP devices using ASP, the amazingly
useful response.redirect doesn't work. It works on most emulators (so you
may find this out rather later in the development cycle than you'd like),
but it bombs out on real WAP phones.

Here's a way to get around it.

Your normal code (that won't work) might look like:

<%@ LANGUAGE="VBSCRIPT" %>
<%
If SomethingOrAnother = 1 then
	response.redirect "error.wml"
Else
	'lots of code
End If
%>

Change this to:

<%@ LANGUAGE="VBSCRIPT" %>
<%
Sub MainSub()
	If SomethingOrAnother = 1 then
		redir("error.wml")
		Exit Sub
	Else
		'lots of code
	End If
End Sub
Call MainSub()
%>

...with "redir" being the following function (ideally in an Include file, so
you can call it from all of your pages:

<%
Sub redir(FileToRD2)
Response.ContentType = "text/vnd.wap.wml"
MyStr = "<?xml version=""1.0""?><!DOCTYPE wml PUBLIC ""-//WAPFORUM//DTD WML
1.1//EN"" "
MyStr = MyStr & """http://www.wapforum.org/DTD/wml_1.1.xml"">" & vbcrlf
MyStr = MyStr & "<wml>" & vbcrlf
MyStr = MyStr & "<card id=""main"" title=""AngloINFO"" onenterforward=""" &
FileToRD2 & """>"
MyStr = MyStr & "<onevent type=""onenterbackward""><prev/></onevent>"
MyStr = MyStr & "</card></wml>"
Response.Write MyStr
end Sub
%>

By enclosing your main code in a Sub ("MainSub") which you then call, you
get access to the all important "Exit Sub" bit, that stops processing. The
function, merely passes the new URL into a WML page which automatically
forwards it and, when entered from somewhere forward in the stack, redirects
backwords. The page is thus, essentially invisible.

</tip>

-------------------
Mike Hardaker
Founder & Publisher
AngloINFO
www.angloinfo.com






More information about the thelist mailing list