Using the ScriptPath of the ASP.NET Ajax ScriptManager

An entry about asp.net | ajax Publication date 22. March 2007 19:47

Normally, all the javascript for ASP.NET Ajax is loaded through a custom http handler - namely the ScriptResource.axd handler. However, I host this blog on a subdomain, which seemed to cause some friction with the handler settings in the web.config due to the directory structure my host use for subdomains. I couldn't quite manage to untagle it, so I started looking for other ways to solve this - and that's when I remembered the ScriptPath property that's on the ScriptManager.

Basically, ScriptPath lets you tell ASP.NET Ajax where it should load its javascript files from. If this property is set, it will look for the javascripts in the folder you specify instead of using the ScriptResource.axd handler to load them.

To get this to work, you need to copy all the ASP.NET Ajax javascript source files into some folder on your domain. Now the folder structure here is very important - but luckily it's all lying readily available where ASP.NET Ajax was installed (typically C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025).

Just copy the MicrosoftAjaxLibrary folder onto your site, and you can set the ScriptPath property to ~\MicrosoftAjaxLibrary, and thats it :)

But hang on... what about the Ajax Control Toolkit?

Yup, we need those javascript files aswell to use that. Create the folder AjaxControlToolkit\1.0.10201.0/ within ~\MicrosoftAjaxLibrary, and place all the toolkit client files there - you'll find them in the AjaxControlToolkit\obj\Release folder inside wherever you unzipped the toolkit. Don't forget to use the correct version number for the folder if your toolkit is a newer/older version than in the example above, or you'll be in trouble.

And that's it, ASP.NET Ajax plus the AjaxControlToolkit working like a charm without the ScriptResource.axd. Another great use for this, is if you want to tinker around with the javascript source files.

Currently rated 4.6 by 5 people

  • Currently 4.6/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Comments

Powered by BlogEngine.NET 1.4.5.0

Welcome!

My name is Fredrik Kalseth, and this is my blog - thanks for visiting! I am fortunate enough to work with what I love for a living, and this blog is essentially the biproduct of that.

I work as a senior consultant for Capgemini, and am also an active participant in the Norwegian .NET community, as an avid attendee but also as a speaker (most recently at NNUG and MSDN Live).

As a developer, I have a wide circle of interest. My primary passion is for agile, test-driven development, with focus on best practices and clean code. That said, I also love to work on the frontend, especially with web development.

On Twitter? My handle is fkalseth. On LinkedIn? I`m there too.

Disclaimer

This is a personal blog; any opinions expressed here are my own and do not necessarily reflect those of my employer. All content herein is my own original creation, and as such is protected by copyright law. Unless otherwise stated, all source code posted on this blog is freely usable under the Microsoft Permissive License.

What Readers Talk About

Comment RSS