Server.Transferrequest () and getting the current url

Say in my "Page_init ()" "a.aspx", I just have server.transferrequest ("b.aspx").

This works fine, displays content for "b.aspx", and the browser browser still remains on "a.aspx".

Happy Days.

However, does anyone know how to see this URL from my "b.aspx" (resulting page)?

The usual request.rawurl and request.url.absoluteuri return the current page as "b.aspx".

+3
source share
5 answers

Server.TransferRequest URL. , , , .

( ), Response.Redirect.

+2

, , -, , .

+1

PreviousPage, , :

string previousPagesUrl = PreviousPage.Request.RawUrl;

: @maxp, , PreviousPage Server.Transfer .

null , :

  • .
  • .
+1
source

Have you tried this method:

public void Transfer(string path, bool preserveForm )

http://msdn.microsoft.com/en-us/library/caxa892w.aspx

I currently have the same problem, and I found that the Server object has this parameter on transfer, which gives you the option to keep the original request form or not.

0
source
NameValueCollection headers = new NameValueCollection();
headers["RawUrl"] = HttpContext.Current.Request.RawUrl;
Server.TransferRequest("b.aspx", true, null, headers);

And then use Headers["RawUrl"]at b.aspx.

0
source

Source: https://habr.com/ru/post/1713336/


All Articles