About me etc

My name is Ross Hawkins and I'm an IT Consultant based in Auckland, New Zealand. My current work revolves around ASP.NET, C#, Ajax, SQL Server, and a mix of other Microsoft development technologies. Previously I spent about 11 years working with Lotus Notes/Domino.



 

    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

    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


     


    Other stuff etc

    A quick mix of insights into other parts of my life, including photos, images, and comics.



     

    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

    # qdqnepfn

    qdqnepfn
    3/4/2008 5:48 AM | qdqnepfn
    Gravatar

    # Buy ambien 12.5 mgm overnight mail md consultation.

    Buy ambien 12.5 mgm overnight mail md consultation. Buy ambien.
    3/18/2008 8:55 AM | Buy ambien online cod.
    Gravatar

    # Ambien without a prescription.

    Ambien no prescription needed.
    3/23/2008 2:26 PM | Cheaper ambien prescription.
    Gravatar

    # Tramadol cheap cod.

    Tramadol 180 cod. Buy tramadol online cod.
    4/6/2008 10:35 PM | Buy tramadol online cod.
    Gravatar

    # t966a

    t366t
    4/21/2008 11:54 PM | ma967zda
    Gravatar

    # 

    ASP.NET Validation stops working when using HTTP Compression
    5/2/2008 2:05 AM | The3Factory
    Gravatar

    # Pissing.

    Pissing.
    5/15/2008 10:03 AM | Pissing.
    Gravatar

    # Airfare.

    Airfare.
    5/15/2008 12:13 PM | Airfare.
    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

    # Asian interracial porn.

    Asian porn. Free asian porn movies.
    5/18/2008 5:34 AM | Tgp asian porn.
    Gravatar

    # Bisexual.

    Alanis morissette bisexual. Free bisexual men stories pictures.
    5/20/2008 1:59 PM | Bisexual porn.
    Gravatar

    # Lesbian anal.

    Anal sex. Free anal creampie pics. Anal teen. Anal torture. Anal. Anal girls.
    5/21/2008 2:34 PM | Anal intercourse.
    Gravatar

    # Cheap airline tickets.

    Dirt cheap airline tickets. Cheap airline tickets.
    5/27/2008 1:45 PM | Cheap airline tickets.
    Gravatar

    # Scat shitting.

    Shitting videos. Shitting black. Women pooping shitting scat picture. Girls pissing and shitting. Scat slave femdom shitting movie clips. Free shitting movie clips. Shitting.
    6/19/2008 11:48 PM | Shitting links.
    Gravatar

    # Incest stories.

    Teen incest stories. Mature incest. Incest erotic stories. Incest. Incest free.
    6/23/2008 8:47 AM | Incest sex.
    Gravatar

    # Incest sex.

    Incest taboo. Father daughter incest. Incest photos. Free incest pics free. Incest sex stories. Incest. Free incest. Incest stories. Free incest photos.
    6/23/2008 8:57 AM | Stories of incest.
    Gravatar

    # Incest stories.

    Incest pics. Gay incest. Incest stories.
    6/24/2008 9:45 AM | Incest sex stories.
    Gravatar

    # Boobs.

    Boobs.
    6/25/2008 9:46 AM | Boobs.

    Post Comment

    Title  
    Name  
    Email
    Url
    Comment   
    Please add 8 and 5 and type the answer here: