Tuesday, 30 December 2008

JS error "Sys is not defined" caused by HttpModule

I have an ASP.NET application that makes use of Ajax Control Toolkit. Everything was working fine until I decided to implement authentication on application level using HttpModules. It's basically about authenticating each request to your application with one piece of code - before each request is processed the code defined in appropriate HttpModule is executed. You can read more on that here or here.

After I've configured my application to use the custom authentication HttpModule all controls from Ajax Control Toolkit (ACT) stopped working. Instead, I was getting JavaScript error "Sys is not defined". The cause of that was the authentication module, which was checking URL parameters to grant access to requested resources.

I've discovered that ACT was dynamically loading additional .resx files from the server. The dynamic requests (sort of Ajax calls) didn't contain appropriate parameters so they were rejected.


I've added additional if clause to my authentication code that was allowing all requests to .axd files to pass, regardless parameters. I could do that since none of the files created by me was in that format and I didn't have to care about authentication when such files are requested. Of course, I'm open for suggestions how to resolve this in cleaner way.

Friday, 5 December 2008

How to get assembly file from GAC?

The .Net application I'm currently working on uses libraries from Global Assembly Cache (GAC). To see the libraries available in GAC just navigate to C:\windows\assembly with regular windows file explorer. The explorer will display the GAC content in a different way than regular files. You'll only see the list of available libraries. You can add assemblies to GAC by drag'n'drop:

Global Assembly CacheHowever, this view will only allow you to see the current GAC content and add/update libraries. This has some limitations e.g.:
  • It won't let you get the actual library file. Sometimes you may need to do that e.g. to backup file from GAC before you replace it.

  • You can't add files of different types e.g. PDB files. This could be useful if you'd like to see the line numbers in stack trace.

  • ...

You can bypass all those limitations by using different tool to access the folder content e.g. console or Total Commander. Note that the libraries placed in GAC are not saved directly in c:\windows\assembly folder. The dll-s you're looking for should be available at following path:

We're looking for library with name = Kainos.Framework.Web, version = and PublicTokenKey = 1111aaaa1111aaaa. You can find it at:
Once you access the folder you can copy the assembly files, add pdb files, etc.