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.


Tags: ,

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

Like this? Share it!

  • # Troubleshooting WebResource.axd
    Gravatar
    Commented on 2/22/2007 7:08 AM

    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

  • # Troubleshooting WebResource.axd
    Gravatar
    Commented on 2/24/2007 1:36 PM

    Hi Jeanette,

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

  • # Troubleshooting WebResource.axd
    Gravatar
    Commented on 2/25/2007 2:56 PM

    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

  • # Troubleshooting WebResource.axd
    Gravatar
    Commented on 2/25/2007 11:06 PM

    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

  • # Troubleshooting WebResource.axd
    Gravatar
    Commented on 2/28/2007 5:24 AM

    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

  • # Troubleshooting WebResource.axd
    Gravatar
    Commented on 2/28/2007 3:56 PM

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

  • # Troubleshooting WebResource.axd
    Gravatar
    Commented on 3/6/2007 11:16 AM

    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;

    }

  • # Troubleshooting WebResource.axd
    Gravatar
    Commented on 4/10/2007 8:42 AM

    This was a great help! Thanks!

  • # Troubleshooting WebResource.axd
    Gravatar
    Commented on 4/18/2007 6:11 AM

    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.

  • # Troubleshooting WebResource.axd
    Gravatar
    Commented on 5/5/2007 12:39 PM

    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!

  • # Troubleshooting WebResource.axd
    Gravatar
    Commented on 5/8/2007 1:20 AM

    this is dotnet stuff

  • # Troubleshooting WebResource.axd
    Gravatar
    Commented on 5/12/2007 10:35 AM

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

  • # Troubleshooting WebResource.axd
    Gravatar
    Commented on 5/16/2007 3:08 AM

    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

  • # Troubleshooting WebResource.axd
    Gravatar
    Commented on 5/16/2007 10:40 PM

    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?

  • # Troubleshooting WebResource.axd
    Gravatar
    Commented on 5/18/2007 3:43 AM

    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.

  • # Troubleshooting WebResource.axd
    Gravatar
    Commented on 6/22/2007 12:11 AM

    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

  • # Troubleshooting WebResource.axd
    Gravatar
    Commented on 7/3/2007 7:41 PM

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

  • # Troubleshooting WebResource.axd
    Gravatar
    Commented on 8/10/2007 5:33 AM

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

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 10/2/2007 11:30 PM

    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.

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 10/12/2007 3:11 AM

    you're so cool!!!

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 10/17/2007 11:33 AM

    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

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 11/10/2007 6:03 AM

    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

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 2/4/2008 5:20 AM

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

    That Worked!!

    Thanks

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 5/16/2008 7:05 PM

    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.

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 5/16/2008 7:33 PM

    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.

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 10/18/2008 6:48 AM

    Thanks so much!

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 10/25/2008 8:45 AM

    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

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 11/7/2008 2:32 AM

    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...

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 11/14/2008 4:33 AM

    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

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 3/5/2009 1:13 AM

    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.

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 6/10/2009 5:13 AM

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

    great Post, thank you very much

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 7/6/2009 11:36 PM

    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.

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 7/14/2009 12:25 AM

    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.

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 8/1/2009 12:41 AM

    Good post - thanks a million

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 8/20/2009 9:44 AM

    "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...

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 9/19/2009 2:28 AM

    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!

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 10/15/2009 3:24 PM

    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.

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 12/3/2009 6:26 PM


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

    today i can sleep well after 2 days.


    once again thank you...

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 12/23/2009 11:11 PM

    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 ?

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 9/11/2010 7:07 AM

    Thanks a million! We've got a load balanced sharepoint farm and IE was intermittently throwing an "JScript runtime error: Object expected" when we hovered the mouse over the top link bar (debugging showed it to be the call to Menu_HoverStatic(this)). After ensuring the machinekeys were identical between the servers (which they weren't) it worked. Thanks again - would have NEVER found this otherwise!

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 10/13/2010 3:25 PM

    This post helped, but was a little misleading. I thought I found the problem because I recently added the blowery compressor to my web site and I was experiencing this issue.

    I can tell you exactly what I did to fix it. Instead of just checking to make sure the box for "verify that file exists" is unchecked, it needs to be toggled on and saved and then toggled off again. That is what fixed it.

    Now, I don't rule out that the blowery compressor caused the issue in the first place, and I will have to do more testing with it before releasing to production.

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 12/29/2010 9:45 PM

    Guys please check your server date time...whether they are correct or not.

    Request to webresource.axd may failed due to

    specified argument was out of the range of valid values. parameter name utcdate


  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 3/4/2011 9:43 PM

    Thank you for the post I've been banging my head against a wall for a while now on this one. For me it was the CompressionModule for BlogEngine.NET that was causing the problem. I needed to comment it out to get it working.

    Thanks for the great post.

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 3/30/2011 5:40 PM

    Hi,

    I am getting HTTP 404 for WebResource.axd. My application is hosted by a cluster of Windows 2003 servers. If I run it on individual server it works but not from cluster. What can be the problem?

    I have machine key / validation key values identical for both the nodes.
    I have IIS configurations in place for both the nodes for .axd extension and "verify that file exists" unchecked.

    Please help.

    Thanks,
    Yogesh

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 6/20/2011 3:49 AM

    This problem was eventually solved by my hosting service:

    --
    We have checked and found that your application requires integrated asp.net 4.0 application pool.
    We have configured your domain to use aps.net 4.0 pool and now its not throwing any error.
    ---

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 11/19/2011 12:03 AM

    Hello,

    I am facing exactly the same issue. I have already made sure that (IIS/Website/Properties, Home Directory, Configuration, Application Extensions, .axd) has "Verify that file exists" option is unchecked in both of my frontend server's.

    Kindly help me out.

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 12/7/2011 7:39 PM

    Hi,
    I am getting following error:

    Webpage error details

    User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Win64; x64; Trident/5.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)
    Timestamp: Wed, 7 Dec 2011 06:12:16 UTC


    Message: Unable to get value of the property 'replace': object is null or undefined
    Line: 1
    Char: 6446
    Code: 0
    URI: localhost/.../WebResource.axd

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 10/15/2012 6:09 AM

    Friends I still have this problem where intermittently the webresource.axd and javascript don't load. I can't figure this out. THe application has been working since 2004 and all of a sudden I have this problem

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 3/6/2013 4:55 AM

    Hi,
    i am getting Javascript error after i modified the web.config [debug compilation = false ]

    i have embedded javascript in my code using webResource

    [assembly: WebResource("ClientModels.js", "text/javascript")]

    Previously it has debug compilation = "true" and it was working fine but after modification Compilation debug ="false" targetFramework ="4.0"

    Iam Using IIS7-integrated pipeline mode and not using any HTTPcompression

    Thanks

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 4/23/2013 5:37 PM

    Thanks a lot!!! This solved my issue... It was Machinekey problem... Thank you very much..

  • # re: Troubleshooting WebResource.axd
    Gravatar
    Commented on 12/26/2016 11:35 PM

    i am keep getting below error on my website, Kindly help

    SCRIPT5009: 'WebForm_SaveScrollPositionSubmit' is undefined

    Thanks

Post a comment
Please add 2 and 6 and type the answer here:
Remember me?
Ensure the word in this box says 'orange':