5

ASP.NET automatically includes the following script tag:

<script src="/WebResource.axd?d=8H_C0aee9xE8e9a-3YoRhA2&amp;t=633413907763620168" type="text/javascript"></script>

However the clients site is being proxied through another site. So the URL to the root of their site is:

http://domain.com/somename/

So I need to prefix the WebResource.axd with /somename so the resulting tag will look like this:

<script src="/somename/WebResource.axd?d=8H_C0aee9xE8e9a-3YoRhA2&amp;t=633413907763620168" type="text/javascript"></script>

What I am not sure is how to actually set this? Is there a web.config setting I can set so it has this prefix?

Michael Edwards
  • 6,308
  • 6
  • 44
  • 75

3 Answers3

2

I think that this function Response.ApplyAppPathModifier("You path"); can make the work for you.

on Global.asax

protected void Application_PreRequestHandlerExecute(object sender, EventArgs e)
{
   string HereIsMyFileName = HttpContext.Current.Request.RawUrl;

   if HereIsMyFileName contains the "webresource.axd"
     then change it to what ever you like using
        Response.ApplyAppPathModifier("You path");

Hope that this helps.

Aristos
  • 66,005
  • 16
  • 114
  • 150
  • Didn't work for me, then used solution similar to http://stackoverflow.com/questions/5536536/change-the-requested-url-of-webresource-axd – anre Sep 23 '14 at 12:32
  • @anre Thank you for the information. I see the answer you note, and I never go there, to scan and replace the full page html for a string. Too much memory, time, and probably errors if you change something else. Now I do not know why this is not work for you, its 4 years answer.... if I find the time I will check it out. – Aristos Sep 23 '14 at 12:49
1

Well, you're pretty much screwed here. Reflector reveals with all certainty that this is hard-coded and cannot be changed.

Your only option is to find a workaround. For example, you can create a filter (HttpFilter) that would replace "WebResource.axd" with appropriate address.

Another thing I can think of - if you control the proxy server, you could have it filter out such requests and redirect them appropriately based on Referrer.

Good luck.

Fyodor Soikin
  • 78,590
  • 9
  • 125
  • 172
0

You can catch the output stream and search/replace "/WebResource" with "WebResource" or with the path you need...

Try the solution from here: Change the requested url of WebResource.axd

Stefan
  • 1