Link to home
Start Free TrialLog in
Avatar of jrwj
jrwj

asked on

change url address before issueing server.transfer command

Hello

I am would to like to
   build a dynamic url,
   then past this url to the server.transfer,
   and lastly, update the url displayed in the client browser.

Right now, I am relegated to having to issue a response.redirect; I would like to save  a round trip. Is it possible. In the past, I've spent hours trying this solution and never solved it. But, I hadn't remembered to pose this question to this bright community.

this is my response.redirect that I am currently using and would like to substitute this for server.transfer... (and do the additional things i  previously mentioned)

        // redirect (resets both child and parent usercontrols)
        Response.Redirect(Request.Url.ToString().Substring(0, Request.Url.ToString().IndexOf(Request.Path)) + Request.Path + "?page=view&esrchid=" + Request.QueryString["esrchid"].ToString() + "&srchid=14");


Again, my hangup is I am using usrcontrols and would like my individual user controls to act autonomous of each other based on the parameters in the querystring, and also avoid an extra browser round trip when user response.redirect.

below are my botched examples from the past..

        //Server.Transfer("~/admin/employeeview.aspx?page=edit&esrchid=" + Request.QueryString["esrchid"].ToString()+ "&srchid=14");
        //RouteCollection.GetVirtualPath( context, new RouteValueDictionary( {"page", "edit"}, {"esrchid", Request.QueryString["esrchid"].ToString()}, {"srchid", "14"} ) );

        ///System.Web.HttpContext.Current.Server.MapPath("~") + "~/admin/employeeview.aspx?page=edit&esrchid=" + Request.QueryString["esrchid"].ToString() + "&srchid=14";

        // //   Response.AddHeader("Location", "~/admin/employeeview.aspx?page=edit&esrchid=" + Request.QueryString["esrchid"].ToString()+ "&srchid=14");
        //System.Web.HttpContext.Current.RewritePath("~/admin/employeeview.aspx?page=edit&esrchid=" + Request.QueryString["esrchid"].ToString() + "&srchid=14");


Thanks for your insights...
Avatar of Ravi Vaddadi
Ravi Vaddadi
Flag of United States of America image

It should work.
Use Path.Combine method with Server.MapPath to build the path and once the path is built you can pass it to Server.Transfer
Avatar of jrwj
jrwj

ASKER

Thanks. I was successful at building the path. I am not successfully at programmatically updating displayed url, either prior or after issuing the server.transfer. Could you or someone help with this?
ASKER CERTIFIED SOLUTION
Avatar of drypz
drypz
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
jrwj, Sorry for the confusion. I never thought that you wanted to update the url in the address bar of the browser.

Response.Redirect comes back to the client in the process of transferring to another page so it updates the url and Server.Transfer does not update the url as it never comes to the client in the process.

There is no other way to update the url in the address bar of the browser except for Response.Redirect.

Sorry I mistook your problem.
Avatar of jrwj

ASKER

Thanks for the answer about my specific question. I found the referred article helpful. I am still not satisfied without having new options mentioned suggested.