Note that there are some explanatory texts on larger screens.

plurals
  1. POMap path to different domain
    primarykey
    data
    text
    <p>I want to be able to map a path to a different domain but keep the original address in the address bar. Is there a way to code this or is it in IIS. I preferably would like a coded method if possible.</p> <p>I have a link whose href is like this "http://www.example.com/invproxy.aspx?id=1&amp;batch=1". I want to have that map to "http://www.otherdomain.com/Files/TheFileRequest.aspx".</p> <p>I generate the path to map to using the querystring of the original request. It works with Server.Transfer or Response.Redirect but i want the address bar to still say the originally requested URL. Is this possible?</p> <p>Thanks</p> <p>EDIT: I have solved the issue (probably not the most economical way) but below is the code I am using in the Page_load event of invproxy.aspx</p> <pre><code>// Just test file, no code to select path yet. string requestPath = "http://www.otherdomain.com/Files/TestFile.pdf"; // Setup the request for the PDF File HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(requestPath); // Get the response from otherdomain.com HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); // Assign the invproxy response the PDF ContentType Response.ContentType = "application/pdf"; // Get the body of the response in a stream object Stream s = resp.GetResponseStream(); // Create a byte array to be read into from the stream byte[] buffer = new byte[resp.ContentLength]; int position = 0; while (true) { //Read bytes one by one, slow but causes errors trying to read the whole thing. //I need to use chunks here. int b = s.ReadByte(); if (b == -1) { //This is the end of the stream break; } else { //Set the byte at the current position to the value just read buffer[position] = (byte)b; //Advance the position by one. position++; } } //breakpoint debugging string sa = Encoding.Default.GetString(buffer); //Write the file to the invproxy response. Response.BinaryWrite(buffer); </code></pre> <p>EDIT: Just to the add the finished result, I get my PDF document displayed in a new tab in the browser (where compatible) with the address bar saying <a href="http://www.example.com/invproxy?myquerystring" rel="nofollow">http://www.example.com/invproxy?myquerystring</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload