0

i googled many samples, all show such code

Server.Transfer("/default.asp?p=news")

but i get error -An invalid character was specified in the Path parameter for the MapPath method.

can you help me?

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
kusanagi
  • 14,296
  • 20
  • 86
  • 111

3 Answers3

3

Server.Transfer method actually doesn't support any kind of querystring specified in the path. You can try to store the query parameter in a session value instead.

Some discussions: http://classicasp.aspfaq.com/general/why-won-t-querystring-values-work-with-server-execute/server-transfer.html

tshao
  • 1,127
  • 2
  • 8
  • 23
0

The following might be a work around to using server.transfer or response.redirect.

Response.Write "<script language=javascript>window.location.href = '/default.asp?p=news';</script>"
chaltahai
  • 117
  • 10
0

You would have to include your querystring on the page that does the server transfer.

Ie:

page.asp?p=news would include:

  Server.Transfer("default.asp")

default.asp would include:

  sParam = Request("p") '<-- Your querystring value from page.asp

This should work, or if your app isn't flexible to do this, you can use Session to pass the value. It says here which methods are allowed for passing variables using Server.Transfer: http://msdn.microsoft.com/en-us/library/ms525800%28v=vs.90%29.aspx

Control Freak
  • 12,965
  • 30
  • 94
  • 145