Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the WebResource.axd URL

Tags:

c#

.net

asp.net

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?

like image 370
Michael Edwards Avatar asked Oct 25 '22 19:10

Michael Edwards


1 Answers

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.

like image 104
Aristos Avatar answered Nov 08 '22 10:11

Aristos