Using Context.RewritePath to rewrite to a different-domain
this is my first post on SO. :) My goal is, in the application (which is an existing VB.NET app shudder), whenever a request is encountered for a resource such as:
That it gets rewritten to
There are 10GB of images on the production site so for local development, we just want to rewrite the request so we don't have to download and shuffle around 10GB of product images.
I've tried the following in Application_BeginRequest() keep in mind I'm simplifying this to illustrate the problem I'm running into:
If (url1.IndexOf("itemimages") > 0) Then Dim app As HttpApplication = CType(sender, HttpApplication) app.Context.RewritePath("https://www.google.com/images/srpr/logo3w.png") End If
The error I get is:
'https:/www.google.com/images/srpr/logo3w.png' is not a valid virtual path.
Note the single forward slash in https:/www.google.com, even though I specified two slashes. Plus, it explicitly mentions that it's not a valid VIRTUAL path so apparently I can't specify an absolute URL here.
How can I rewrite requests to "/itemimages/image.png" to "http://www.website.com/itemimages/image.png"? I'm posting this in C# also because I'm more comfortable with that language anyways and can probably convert any solution between the two pretty easily.
Context.RewritePath processes the request under a different path with ASP.Net. It doesn't make sense to do that with an external server.
You want Response.Redirect.