Troubleshooting WebResource.axd

The .NET 2.0 framework changed the way clientside JavaScript is delivered to the browser. Previously, ASP.NET 1.1 used the aspnet_client directory whereas now 2.0 uses WebResource.axd.

When things go wrong, you'll see JavaScript errors about missing functions, including the now infamous 'WebForm_PostBackOptions is undefined'. After having this problem in one of my applications, doing a lot of googling on it, and eventually fixing it, I feel it's my turn to add to the fray of people writing about this in the hope that it helps someone.

There are a few things which can go wrong with WebResource.axd. Some of these are specific to compression (and in my case, the compression I'll be writing about is pretty specific to the Blowery module, however you might find some of the symptoms apply to other compression techniques), some are specific to Network Load balancing (NLB), and some are specific to IIS.

A few key things which can cause issues with WebResource.axd:

  • Missing compression exclusion
  • Slight error with compression module
  • Missing MachineKey / ValidationKey
  • Bad IIS setup, specifically the Application extension mapping

If you're lucky like I was, then you could have elements from all of the above in your environment. This makes for a lot of fun, especially given that the client errors can be somewhat intermittent. Unfortunately, I haven't managed to find much of a pattern to it. Some clients work, and some don't. You can break a working client, and you can fix a broken one, but it's kinda random. I know that's a fairly useless way to start out, but it gets better, I promise.

The first thing to do if you're having the JavaScript errors is to determine if they're being caused by a "missing" WebResource.axd. Simply view the source of the page which is breaking and find the js include line which references WebResource.axd. Copy the url, and paste it into your browser. You'll get a blank file loaded. Do this in a client which is working, and you'll get a file filled with JavaScript functions - funny that.

During my googling, I came across a few people who recommended simply getting the WebResource.axd from the cache of a working client, and copying it to the root of your application. I really don't advise this. On it's own, this didn't work for me anyway. My only thought is that these people intended you to update all the pages in your application and included a hardcoded reference to this file. Nasty. If you view the source of a lot of your pages, you'll notice that the include to WebResource.axd is made only on pages which need it. It's nice to let the .NET Framework decide these things rather than having to go through an entire application and work it out.

Compression
If you're running compression, you can confirm whether it's causing the problem by temporarily disabling it entirely. If you're using Blowery, then simply remove the httpmodule line in web.config (or web.configs if you're running in a load balanced environment), save, and test.

Disabling compression isn't really a great long term solution, so lets deal with this in a slightly more permanent way. First thing to do, is too add an exclusion for WebResource.axd in your web.config. If you're using blowery, it will look something like this:

<httpCompress preferredAlgorithm="deflate" compressionLevel="high">  <excludedMimeTypes>   <add type="image/jpeg"/>   <add type="image/gif"/>  </excludedMimeTypes>  <excludedPaths>   <add path="WebResource.axd"/>  </excludedPaths> </httpCompress> 

This is needed, however in my case it wasn't fixing all clients. It fixed some, but not all. After some frustrated googling and testing, I downloaded the latest version of Blowery (Blowery HttpCompress v6 for .net 2.0), and applied a small code change to line 85 of HttpCompress.cs:

From:
string realPath = app.Request.Path.Remove(0, app.Request.ApplicationPath.Length+1);

To:
string realPath = Path.GetFileName(app.Request.Path);

I found this code change via the DNN Forums: Http Compression and WebResource.axd.

Bad IIS Setup
If you're seeing 404 errors in your IIS logs (If you don't know where your application's logs are kept, then check Website Properties in IIS manager to find out. Clicking on 'Properties' next to the Enable Logging checkbox will bring up a dialog that will show you were the logs for this application are located.) then it's possible you need to make a change to your IIS config. From IIS Manager, select the properties for your application's website, and goto the 'Home Directory' tab. Click 'Configuration', then bring up the list of extension mappings on the 'Mappings' tab. You're obviously looking for .AXD, and if that's not there you need to create it. The important thing is to make sure "Verify File Exists" is deselected, as shown here:

If you have load balanced servers, then make sure you repeat this for all servers. Also you can probably do this at your top level website if you wanted to - the servers I was working on had a mix of ASP.NET 1.1 and 2.0 applications, so I tried to limit my changes to the end level website.

Network Load Balancing (NLB)
NLB is also known to cause issues with WebResource.axd. Even without thinking of clustering issues, it means you need to have your IIS setup properly twice. If you're having problems intermittently, then double check your config across both servers first and make sure they're identical. You can also hardcode an entry in your hosts file to specifically point to a single server in order to see if it works on one and not another. If you wanted to be incredibly drastic you could even break the NLB cluster, however I don't particularly recommend that option.

If your IIS setup is identical and you're still having issues, then check your MachineKey and ValidationKey nodes in your web.configs. They must be set to the same value on all nodes. If you're using something like SQL Session State, then this is probably going to be the case already. Here are a couple of useful links about MachineKey and ValidationKey:

Hopefully you'll find your symptoms and their solution in this article. If your problem turned out to be something different, please leave a comment or drop me a line so I can add your symptoms and solution here.

Update: If you're having AXD related problems with the SQL Server Report Viewer web control under Longhorn/IIS7, then this link might be of help to you.


Technorati tags: ,

 Print | Posted on Sunday, October 08, 2006 2:15 PM |


Feedback

Gravatar

# Troubleshooting WebResource.axd

You absolutely Rock! I have been searching all over for why I was getting these javascript errors with a 2.0 page using validators. I found the info about creating a blank .axd file - which got rid of the error with the link to this file, but my validators were still generating the error. I had done two things that made me uncomfortable - created the blank axd file and removed my validators in order to get it to work.

One of your solutions above corrected all my issues - simply map the .axd extention!

Thank you so much.

Jeannette

2/22/2007 7:08 AM | Jeannette Kescenovitz

Gravatar

# Troubleshooting WebResource.axd

Hi Jeanette,

Thanks for your comment, and I'm glad you found the article useful!

2/24/2007 1:36 PM | Ross Hawkins

Gravatar

# Troubleshooting WebResource.axd

Brilliant article. I manage to solve my javascript problem after change the Source code and re-compile the library. Now my website:http://AquariumFishExporter.com is power with gZip Compression. Check it out against the http compression checker:http://www.port80software.com/products/httpzip/compresscheck

2/25/2007 2:56 PM | PohEe.com

Gravatar

# Troubleshooting WebResource.axd

I just include a complete guide [http://pohee.com/2007/02/http-compression-in-aspnet-20/] to enable Http compression using Blowery library with the WebResource.axd exclusion guide from here. 18

2/25/2007 11:06 PM | PohEe.com

Gravatar

# Troubleshooting WebResource.axd

I looked all over the place and you were the only one that solved my issue. Maybe because you covered all of the bases. Thanks!! verey usefull. 18

2/28/2007 5:24 AM | Adam

Gravatar

# Troubleshooting WebResource.axd

Thanks for the comments guys, I'm glad you all found the article helpful! «

2/28/2007 3:56 PM | Ross Hawkins

Gravatar

# Troubleshooting WebResource.axd

This problem can also happen with DNN. Change the httpmodule.cs to this:

Basically add a fileName check and add to the exclusion.

string realPath = app.Request.Url.PathAndQuery;

string fileName= Path.GetFileName(app.Request.Path);

// get the config settings

Settings settings = Settings.GetSettings();

if (settings == null)

return;

bool compress = true;

if (settings.PreferredAlgorithm == Algorithms.None || (settings.PreferredAlgorithm == Algorithms.Deflate && settings.CompressionLevel == CompressionLevels.None))

{

compress = false;

// Terminate processing if both compression and whitespace handling are disabled

if (!settings.Whitespace)

return;

}

string acceptedTypes = app.Request.Headers["Accept-Encoding"];

if (

settings.IsExcludedPath(fileName) ||

settings.IsExcludedPath(realPath) ||

settings.IsExcludedMimeType(app.Response.ContentType) ||

acceptedTypes == null

)

{

// skip if the file path excludes compression

// skip if the MimeType excludes compression

// if we couldn't find the header, bail out

return;

}

3/6/2007 11:16 AM | Blair

Gravatar

# Troubleshooting WebResource.axd

This was a great help! Thanks!

4/10/2007 8:42 AM | kruss1971

Gravatar

# Troubleshooting WebResource.axd

I am getting some erratic behavior due to WebResource.axd.

I upgraded my ASP.NET 1.1 application to 2.0. On my dev machine (Win 2003 server) the application works flawlessly. But on production, the session state gets dropped after Logging in.

Basically, after validating login, I save user roles in session state. Then I redirect user to the application's main page.

But since the session gets deleted, the user is redirected back to Login page.

I have seen similar problem before, but don't know the fix for this.

4/18/2007 6:11 AM | Sanjeev N.

Gravatar

# Troubleshooting WebResource.axd

This apparently is the case causing customized pages in dasBlog losing auto focus capability. after changing the compression level to none, the problem was solved. Thanks!

5/5/2007 12:39 PM | Kerry Wong

Gravatar

# Troubleshooting WebResource.axd

this is dotnet stuff

5/8/2007 1:20 AM | giridhar

Gravatar

# Troubleshooting WebResource.axd

Brilliant! I googled all day looking for a solution to this problem, I tried everything but only here I could find the solution. Thanks!

5/12/2007 10:35 AM | Moly B

Gravatar

# Troubleshooting WebResource.axd

Well - there's one in every bunch right? We have a very serious, confusing issue regarding WebResource.axd: when the site is compiled in debug mode everything works great but in release mode the javascript is not delivered to the browser.

I've tried commenting out all of the http modules in the web.config, changing the membership provider as well as making sure IIS is configured as you describe. It still fails - but as I said - only in release mode.

Any light you could shed on this would be greatly appreciated!

Regards,

Ted

5/16/2007 3:08 AM | ted duncan

Gravatar

# Troubleshooting WebResource.axd

Hi Ted,

Are you building your solution in release mode as well as editing the <compilation debug=”true”/ > switch in your web.config?

Running in debug mode is supposed to modify the caching settings for WebResource.axd so that it's never cached. Is there anything between you and the web server such as a ISA Server or other web cache which could be interfering with things?

5/16/2007 10:40 PM | Ross Hawkins

Gravatar

# Troubleshooting WebResource.axd

Hi,

This is related to sharepoint 2007. When sharepoint is installed on dev boxes, the pages loads fast but after building the test server ,we are getting 401 errors at the the point where webresource.axd loads.

Any help is appreciated

Thanks

Suvarna.

5/18/2007 3:43 AM | Suvarna

Gravatar

# Troubleshooting WebResource.axd

Thanks. As others have said, I searched for several days to fond out why WebResource.axd did not work on my devlopment desktop. I believe it is because of the Check if file exists and did not have "All Verbs" selected. After restarting IIS, it seems to work. Thanks, again. 12

6/22/2007 12:11 AM | PDWINSLOW

Gravatar

# Troubleshooting WebResource.axd

hello sir, this is not solve my problem. i got javascript error of sys object.Is this useful for Ajax?

7/3/2007 7:41 PM | vips

Gravatar

# Troubleshooting WebResource.axd

Thanks, I found that I needed to add the application extension to a virtual directory that my website was under as well.

8/10/2007 5:33 AM | Brian

Gravatar

# re: Troubleshooting WebResource.axd

Adding a .axd extension mapping did not work for me.

However I also had applied a wildcard application mapping to my virtual directory.

Once I uncheck the "Verify that file exists" setting for this mapping, the embedded javascript worked again :)

Thanks.

10/2/2007 11:30 PM | Kevin

Gravatar

# re: Troubleshooting WebResource.axd

you're so cool!!!

10/12/2007 3:11 AM | me

Gravatar

# re: Troubleshooting WebResource.axd

Good advices!
About the first one: 'Missing compression exclusion'
I recently publish a post in my blog about my compression module
for WebResource.axd, so no need to exclude it anymore from the compression

10/17/2007 11:33 AM | Miron

Gravatar

# re: Troubleshooting WebResource.axd

With no compression used, no httpModules, IIS had the .axd file (supposedly) configured without the "Verify file exists" option unchecked, no extra WebResource.axd file in the root directory, here's how I fixed it...

1. Delete the website.
2. Reboot server.
3. Recreate website.

Problem solved. Huh. I'm getting tired of recreating websites that consistently become corrupt on Win2K3...

Thanks for giving me the slight notion that that was what I needed to do. The sad thing is, I have to do it on all my servers periodically after putting a new build out.

-John

11/10/2007 6:03 AM | John Baughman

Gravatar

# re: Troubleshooting WebResource.axd

Tried EVERYTHING... nothing worked... then saw John's post above... deleted website, then re-created it.

That Worked!!

Thanks

2/4/2008 5:20 AM | steph

Gravatar

# re: Troubleshooting WebResource.axd

Tried EVERYTHING... nothing worked... then deleted website, then re-created it and also in global.asax.cs "this.AcquireRequestState += new System.EventHandler(this.Global_AcquireRequestState);" commented this and moved the code to Session_Start and worked. need to find out the stuff inside it.

5/16/2008 7:05 PM | Smitha

Gravatar

# re: Troubleshooting WebResource.axd

My previous comment of commenting Global_AcquireRequestState, is a bad idea, after googling i found thatwe can just give an if condition in the first line of the event and put the whole code in to it will solve it
if (HttpContext.Current.Session != null)
{
//your event code here
}

Note:The problem is caused by a session state acquisition conflict between the handlers in Global.asax (AcquireRequestState in my case) and WebResource.axd.

5/16/2008 7:33 PM | Smitha

Gravatar

# re: Troubleshooting WebResource.axd

Thanks so much!

10/18/2008 6:48 AM | rpc

Gravatar

# re: Troubleshooting WebResource.axd

Thank you so much for this solution! The javascript not loading was driving me crazy and adding the axd extention and ensuring file exists wasn't checked fixed my problem!

Jason

10/25/2008 8:45 AM | Jason Trimble

Gravatar

# re: Troubleshooting WebResource.axd

Hi
I gone thru entier post but still facing the problem. My site is sharepoint site working fine when accessed thru intranet. But gives error of missing webresource.axd when accessed from extranet.
Any idea why? There are no fire wall issues. when i put a link for axd file, it opens the file but when my application is accessed, axd files are missing in temp directory causing javascript errors...

11/7/2008 2:32 AM | ajinkya

Gravatar

# re: Troubleshooting WebResource.axd

The javascript not loading was driving me crazy and adding the axd extention and ensuring file exists wasn't checked fixed my problem.My site at aquarium fish suppliersis sharepoint site working fine when accessed thru intranet

11/14/2008 4:33 AM | kmz

Gravatar

# re: Troubleshooting WebResource.axd

I've spent all morning and half of yesterday afternoon trying to fix this... and one of the comments in here did it:

"However I also had applied a wildcard application mapping to my virtual directory.

Once I uncheck the "Verify that file exists" setting for this mapping, the embedded javascript worked again :)"

Why on earth would a completely unrelated wildcard application mapping cause this error? I have no idea. But after unchecking the verify file exists there, the .axd file was found and my website worked.

3/5/2009 1:13 AM | Andrew Kerrison

Gravatar

# re: Troubleshooting WebResource.axd

Thanks, i spent several days trying to figure out what was wrong.

great Post, thank you very much

6/10/2009 5:13 AM | Eduardo

Gravatar

# re: Troubleshooting WebResource.axd

I have been getting a strange error with regards to WebResource.axd and ScriptResource.axd lately. The background information is as follows: I have developed a records management application with ASP.Net (Dot Net Framework Ver 2.0). The application is installed in 4 different locations (4 different customers) and each one is set up the same way. Each customer utilizes SonicWall as their firewall. I have the application errors forwarded to my blackberry and one particular customer continues to get the following error daily. It does not occur every time someone utilizes the application. It only occurs once or twice a day originating from different locations. I have checked and re-checked my settings in IIS and my application and I am stumped on this one. The error that I receive is 

Error Message: Compilation Error - Check server log.

Error Path: http://192.168.2.4/EWS/EWS/ScriptResource.axd

Or

Error Message: Compilation Error - Check server log.

Error Path: http://192.168.2.4/EWS/EWS/WebResource.axd

The correct virtual path should be http://192.168.2.4/EWS/ but somehow every now and then an extra /EWS is added to the path with throws an error.

Additional Info:

Server OS: Windows Server 2003 SP2, IIS 6.0, ASP.Net 2.0.50727. The server also has ColdFusion 7.0 installed on it (I don't know if this is an issue).

Client (Workstation) OS: Windows XP SP2, IE 8.0, AVG Virus Scan.

Im leaning towards an IE 8 issue or AVG Virus Scan. Is anyone familiar with any problems that they may cause with ASP.Net. My other customers are all setup up with IE 7.0 and use the McAfee Virus Scan that comes with SonicWall. I do not get this error with my other customers.

Any input would be greatly appreciated.

7/6/2009 11:36 PM | Bernard Bobinski

Gravatar

# re: Troubleshooting WebResource.axd

Resolved! It was IE 8.0. All the clients were rolled back to IE 7.0 and no more error messages. Microsoft is getting ridiculous.

7/14/2009 12:25 AM | Bernard Bobinski

Gravatar

# re: Troubleshooting WebResource.axd

Good post - thanks a million

8/1/2009 12:41 AM | Matt Nel

Gravatar

# re: Troubleshooting WebResource.axd

"Adding a .axd extension mapping did not work for me.

However I also had applied a wildcard application mapping to my virtual directory.

Once I uncheck the "Verify that file exists" setting for this mapping, the embedded javascript worked again :)

Thanks."


The comment above that is attributed to "Kevin" was exactly the problem I had. I had a wildcard "*" application mapping that was set to "Verify File Exists", I removed that and it worked, finally... this has taken me forever to research. I have to say that while this problem was elusive, I am constantly amazed at blogs like this or people who comment their ideas and solutions. I would lost without you guys in the .net community. Thanks again for saving me...

8/20/2009 9:44 AM | Ronald Phillips

Gravatar

# re: Troubleshooting WebResource.axd

I have been researching now for hours and nothing seemed to work. The fix was one i used for one the previous problems. For the axd mapping, the path had \\ instead of \ and removing one of these fixed the issue!

9/19/2009 2:28 AM | CodeCruiser

Gravatar

# re: Troubleshooting WebResource.axd

I had a similar issue with webresource.axd showing missing on a clustered IIS 6 server(s) running Server 2k3 Enterprise x64. The issue was resolved by synchronizing the isapi extension with the proper 'bit-level' - ie. specifying the 64bit version of aspnet_isapi.dll for handling .axd files (see screen shot in the article where 'verify file exists' is listed - replace 'framework' in the path with 'framework64'. Don't know why only that entry was running 32bit version, but thought someone might find this info helpful.

10/15/2009 3:24 PM | RogueDeveloper

Gravatar

# re: Troubleshooting WebResource.axd


Thank you.... finally i resolved my issue with this post.

today i can sleep well after 2 days.


once again thank you...

12/3/2009 6:26 PM | Gadda

Gravatar

# re: Troubleshooting WebResource.axd

Thanks for this , works great if you use the default XP Start menu. I could'nt get it to work with the Classic Start menu though. Any chance of a fix ?

12/23/2009 11:11 PM | best casino gaming site

Post Comment

Title  
Name  
Email
Website / Url
 

Your comment

   
Please add 6 and 2 and type the answer here:

About me

My name is Ross Hawkins and I'm a Developer, Consultant and Writer based in Auckland, New Zealand (pictured below!). My current work revolves around ASP.NET, C#, jQuery, Ajax, SQL Server, and a mix of other Microsoft development technologies.

I also have about 14 years of experience with IBM Lotus Notes/Domino and associated technologies. While Notes/Domino is no longer my primary focus I still like to dabble and keep my skills up to date.

I own and run 2 businesses - Hawkins Consulting Services, and Ignition Development.

Bethells Beach, located in sunny West Auckland, New Zealand


Subscribe

Subscribe to this feed


Search


Popular Content

Troubleshooting WebResource.axd

The .NET 2.0 framework changed the way clientside JavaScript is delivered to the browser. Previously, ASP.NET 1.1 used the aspnet_client directory whereas now 2.0 uses WebResource.axd.

Published on October 8, 2006

Microsoft AJAX Extensions: Sys.Debug is null or not an object

One of the breaking changes which was made with the 1.0 release of the Microsoft Ajax Extensions was the renaming of the 'Debug' class to 'Sys.Debug' for reasons of compatiability with other frameworks. Breaking changes like this can often be a source of frustration..

Published on May 22, 2007

Simple ASP.NET Character Counter

A textbox character counter is a pretty simple piece of functionality, and there's a lot of different ways to apply one to your application. The following method is nice and simple, and can be done using only clientside JavaScript if required, or combined with server side code in order to create a more dynamic effect

Published on December 4, 2006

Simple ASP.NET Character Counter - with Master Page Support

A quick update to my previous character counter article adding some changes for those using it with Master Pages.

Published on February 7th, 2009

Adding Tooltips to Gridview Headers

As the title says, this is a very simple but dynamic way of achieving tooltip text on a header column. It's not overly flash, but it's lightweight and quick to implement.

Published on April 15, 2007

SQL Server Web Report Viewer Issues on Windows 2008 Server/IIS7

A fix for another AXD related issue, this time with the SQL Server Web Report Viewer Control which was being served up via IIS7 on a Windows 2008 server.

Published on June 2, 2007
Updated on April 10, 2008


Archives

February, 2010 (1)
January, 2010 (12)
December, 2009 (13)
November, 2009 (11)
October, 2009 (12)
September, 2009 (12)
August, 2009 (2)
July, 2009 (7)
June, 2009 (12)
May, 2009 (9)
April, 2009 (9)
March, 2009 (9)
February, 2009 (8)
January, 2009 (7)
December, 2008 (6)
November, 2008 (7)
October, 2008 (9)
September, 2008 (12)
August, 2008 (9)
July, 2008 (6)
June, 2008 (24)
May, 2008 (13)
April, 2008 (16)
March, 2008 (8)
February, 2008 (10)
January, 2008 (1)
December, 2007 (14)
November, 2007 (11)
October, 2007 (11)
September, 2007 (13)
August, 2007 (11)
July, 2007 (5)
June, 2007 (15)
May, 2007 (11)
April, 2007 (9)
March, 2007 (9)
February, 2007 (10)
January, 2007 (8)
December, 2006 (18)
November, 2006 (11)
October, 2006 (14)
September, 2006 (9)
August, 2006 (10)
July, 2006 (4)
June, 2006 (4)
May, 2006 (6)
April, 2006 (3)
February, 2006 (6)
January, 2006 (10)
September, 2005 (2)
August, 2005 (4)

Post Categories

ASP.NET
AJAX
Amusing
NZ
NZ Trains
Notes/Domino
Visual Studio
Web Development
Miscellaneous
Me
Rugby
C#
SQL


Twitter