asp Server.Transfer put parameter
i googled many samples, all show such code
Server.Transfer("/default.asp?p=news")
but i get error -An invalid character was sp开发者_高级运维ecified in the Path parameter for the MapPath method.
can you help me?
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
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>"
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
精彩评论