[quoted text, click to view] "Paul M." <paul@nospam.fsnet.co.uk> wrote in message
news:bitd7f$bq3$1@news6.svr.pol.co.uk...
> Hi,
> I am trying to populate 3 paramters in an asp .net (vb) page redirect,
> the first one is ok ok and gets populated by the other two get inserted
into
> the url for the redirect as empty strings! Anyone got any clues?? The code
> is below and I have checked that the variables beginning with "g_str" are
> all populated before the code is called. I think its something to do with
> the "&" in the "&Title" and "&Version", do I need to do something to
> those???
>
> Dim strVal_1 as string
> Dim strVal_2 as string
> Dim strVal_3 as string
>
> strVal_1= "?SQL=" & g_strSQL
> strVal_2= "&Title=" + g_strTitle
> strVal_3= "&Version=" + g_strVersion
>
> Response.Redirect("http://localhost/misc/frmEntry.aspx?Error=" & strVal_1
&
> strVal_2 & strVal_3)
>
Consider the resulting url :
http://.../frmEntry.aspx?Error=?SQL={value of g_strsql}&Title={value of
g_strtitle}&Version={value of g_strVersion}
The ? (Question mark) is used to separate the script name (ie: aspx page)
and the parameters and as you can see there are two question marks, thus
your url is malformed and the risk of a partial interpretation is high.
I don't know what is the purpose of the Error parameter, either it contains
all error fields or it is useless:
http://.../frmEntry.aspx?Error=?{value of g_strsql};{value of
g_strtitle};{value of g_strVersion}
In this url there is only one parameter: Error, then you have to split its
value to get error details.
http://.../frmEntry.aspx?SQL={value of g_strsql}&Title={value of
g_strtitle}&Version={value of g_strVersion}
This url is well formed and you should get correct values for the SQL, Title
and Version parameters.
Final note: the Sql and even Title parameters may contain unwanted
characters like ? or & that will again disturb the parsing of the url, it is
strongly recommended to encode the values so that they fit into an url.
The final code should look like :
strVal_1= "?SQL=" & Server.UrlEncode(g_strSQL)
strVal_2= "&Title=" & Server.UrlEncode(g_strTitle)
strVal_3= "&Version=" & g_strVersion
Response.Redirect("http://localhost/misc/frmEntry.aspx=" & strVal_1 &
strVal_2 & strVal_3)
DK