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:
/itemimages/image.png
That it gets rewritten to
http://example.com/itemimages/image.png
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.RewritePathprocesses 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.