Categorías
- 15m
- adsense
- blogging
- consumo
- desarrollo y programación
- .htaccess
- .net
- ajax
- ajax.net
- ant
- apache
- ascii
- bases de datos
- bbpress
- css
- delphi
- dom
- dreamweaver
- eclipse
- emule
- expr. regulares
- firefox
- formularios web
- ftp
- gmail
- google-gwt
- hibernate
- html
- iis
- internet explorer
- java
- javascript
- librerias
- linux
- microformats
- ofimática
- php
- servicios web
- ssl
- ubuntu
- vbscript
- wiki
- wordpress
- xampp
- xml
- economía
- hardware
- hogar
- matemáticas
- motos
- ofertas
- opinión
- recetas
- salud
- Sin categoría
- sistemas operativos
- tecnologia
- tramites y legislación
Cómo servir en local los scripts de AJAX.net
Esto es un truco para cuando no se quiere utilizar los recursos embebidos para servir el Microsoft AJAX JavaScript runtime que permite ejecutar los controles AJAX.NET, y en lugar de ello poder cogerlos de archivos guardados localmente en un directorio de la aplicación. No solo ganaremos a la hora de depurar sino que se reduce considerablemente el tiempo de carga de las páginas.
(pendiente de traducir: fuente original)
Create a directory structure under your web application’s root directory
You’ll need to create a directory structure that corresponds to the attributes of the assembly that normally contains the script files. In your case you’ll can create a subdirectory structure in your web site like this:
ScriptsMicrosoft.Web.Extensions1.0.61025.0. The top directory doesn’t have to be calledScriptsyou can call it anything you wish. SinceMicrosoftAjax.jsis in theMicrosoft.Web.Extensionsassembly, this is why the second directory level is calledMicrosoft.Web.Extensions. The final directory is the version number of the DLL. You can see this from yourweb.config:Copy the ASP.NET AJAX JavaScript runtime files
When you installed ASP.NET AJAX you’ll have had the ASP.NET AJAX JavaScript source files installed, by default into:
C:Program FilesMicrosoft ASP.NETASP.NET 2.0 AJAX Extensionsv1.0.61025ScriptLibraryDebugand
C:Program FilesMicrosoft ASP.NETASP.NET 2.0 AJAX Extensionsv1.0.61025ScriptLibraryReleaseCopy
MicrosoftAjax.jsfrom theDebugdirectory into yourScriptsMicrosoft.Web.Extensions1.0.61025.0directory, and rename it toMicrosoft.Web.Resources.ScriptLibrary.MicrosoftAjax.debug.js. Then do the same forMicrosoftAjaxTimer.jsandMicrosoftAjaxWebForms.jsfollowing the same pattern of adding Microsoft.Web.Resources.ScriptLibrary. to the start of the filename, and then adding .debug in front of the .js.Also copy the same files from the
Releasedirectory but this time rename them without adding the .debug in front of the .js.Now the source files will be picked up whether or not you are running in debug mode.
Set the ScriptPath on your ScriptManager
Finally, set the
ScriptPathproperty on ASP.NET ScriptManager to tell it to source the ASP.NET AJAX runtime from your new directory:Verifying that the JavaScript files are being served from files
If you do a “View Source” in Internet Explorer you should see the JavaScript files being included from the appropriate location:
<script src="Scripts/Microsoft.Web.Extensions/1.0.61025.0/ Microsoft.Web.Resources.ScriptLibrary.MicrosoftAjax.js" type="text/javascript"></script>
Otros artículos de esta serie:
[seriesposts show_date=0 order=asc]