views:

163

answers:

3

Hi,

I know how to pass values between asp.net pages if its on the same virtual but what about of i have sites on different virtual? would it be possible?

say i have this site1

localhost/search/search.aspx

then i have this site2 which processes the result from site1

localhost/result/result.aspx --> notice this is on different virtual to site1

now how would i pass the results from search site to result site.

would that be possible?

A: 

The ASP.NET Button Web Control has a PostBackUrl. You can use this to to cause the post in search.aspx to be sent to result.aspx.

Jeff Widmer
that's not what I meant, I'm not implying how to do redirect, but rather how to pass a value or object during a redirect/transfer.
Juvil John Soriano
A: 

Yes, you can postback to a page in your virtual application by setting the PostBackUrl property of your search button, then access control values send from the page through Page.PreviousPage.

cxfx
hmm... maybe im not explaining this well, as you can see site1 and site2 has different virtual path, meaning Page.PreviousPage does not work at all, or maybe im wrong.
Juvil John Soriano
A: 

1) Querystring approach. Construct a link like so :-

/result/result.aspx?q=my+search+term

Pick it up in your code-behind with ( C# ) :-

Request.QueryString["q"]

2) Or POST the variables via a form.

In your search page :-

<form action="/result/result.aspx" method="post">
  <input name="searchTerm" id="searchTerm" type="text" />
  <input name="go" type="submit" />
</form>

Note the lack of a runat="server" tag on the form.

Pick it up on the code-behind of your results page as :-

Request.Form["searchTerm"]
Paul Alan Taylor
wouldn't it be vulnerable to XSS? beside im trying to pass in a result in a form of an object, i also don't like passing it up as an xml.do you have other ways?
Juvil John Soriano
Your aim is to pass a search term from a page in one virtual directory to get processed by a page in another virtual directory, is it not?All I have suggested here is that you use basic GETs and POSTs to pass this information.All you are passing here is text.
Paul Alan Taylor
Ah ok, scratch that. You actually want to pass results? I took too much stock in "then i have this site2 which processes the result from site1".Why are you processing results on your initial search form? Can't you do it on the results page, where such stuff would logically sit?
Paul Alan Taylor
technicaly that could be done, but business wise its not the way it should be, the user must see and select what the user wanted to process before sending it the site2. so you have to process it somehow and show it to the user which is still in site1.
Juvil John Soriano