How to merge 150+ Get Request for ScriptResource.axd into 1 without CombineScript - ajax

I am using AjaxControlToolKit which results in 150+ Get requests for ScriptResource.axd even when there are 2 controls on the page. My requirement is to minimize this number of requests. I have tried CombineScript = "true" and reduces the number of requests but it is not compatible with the Telerik DLL, hence Telerik gives a JavaScript error and as my application relies heavily on Telerik, I can't choose that option.
Can anyone help me in combining these requests manually without using the CombineScript property of AjaxToolKit Script Manager.

Telerik has its own ScriptManager called RadScriptManager - you can use that to combine your scripts and it will work fine with the telerik controls.
More details in the documentation.

Related

ASP.NET MVC AntiForgeryToken and Caching

I am currently working on an ASP.NET MVC project and came upon an error that seemed peculiar.
In the ASP.NET MVC Templates forms always get an AntiForgeryToken (thus leading me to believe that this is a best practice). However AntiForgeryTokens don't seem to work well with caching.
For example when I open a site with a form including an AntiForgeryToken and I duplicate the browser window both windows have the exact same AntiForgeryToken leading to an exception when posting the form. This problem does not exist when caching is disabled (via ActionFilter NoCache, see Disable browser cache for entire ASP.NET website).
So I guess my question is: Is this supposed to be that way? Is there any other way besides disabling the cache to tackle the problem?
Especially the fact that the default ASP.NET MVC templates contain AntiForgeryTokens but don't disable the cache (and therefore are open to the error described above) makes me wonder.
Thanks in advance!
This is the expected behavior. Caching nicely caches the answer, including the value of the AntiForgeryToken. Disable caching on forms, and in particular on pages that use AntiForgeryToken. If you think about this further, if you're in a data-entry app, do you want to cache your data-entry forms? Probably not. However you do want to cache heavy reports -- even if it's just micro-caching -- a second or two.

how to integrate ajax to my project

What do i need to do for putting ajax functionality to my project.
What tool kit do i need to download or how can i integrate that .
and do i really need to do something for putting update panel for my project?
One method for AJAX enabling your ASP sites is using the AJAX control toolkit (http://www.asp.net/ajax/ajaxcontroltoolkit/samples/) which provides some AJAX functionality using ASP controls that should be familiar to a novice Dot Net developer. AJAX Control Toolkit is a DLL you add to your solution just like other controls. There is then markup for use in the ASP.NET pages.
For more customized and advanced AJAX features, your best bet is using JQuery (http://jquery.com/) and create *.asmx Web Services. JQuery includes a $.ajax() call that will communicate to ASP.NET Web Services using JSON. This SO page may help - Calling ASMX from jQuery and this Encosia blog entry may help - http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/. JQuery is a library of JavaScript files that you download, include in your page, and call into using your own JavaScript files.
I would also recommend that you read the wikipedia entry for AJAX (http://en.wikipedia.org/wiki/Ajax_(programming)) and familiarize yourself with the related technologies.
I think you need to provide a lot more information before we can give youa definitive answer.
Ajax is simply using Javascript to request a webpage - same as a user clicking on a link - except that JavaScript gets the contents of the page requested instead of showing it to the user.
This allows you to request data within JavaScript without refreshing the page.
As you mentioned UpdatePanel, I'm assuming you're using ASP.Net - In which case, .Net 2.0 didn't include AJAX and you needed to get some additional installs to make it work. 3.5 and later includes it natively.
If you're just starting to get into the whole area, I suggest you do some reading about how AJAX works behind the scenes before trying to use it - Understanding what its doing will save you a LOT of headaches later.
FWIW you don't actually need ANYTHING special to make AJAX work - you can write it yourself entirely in JavaScript (I've done this far too many times). As mentioned in Doug's answer, JQuery is fantastic and is worth using even without the AJAX functionality.
If, however, you want to use UpdatePanels and AJAX, the easiest option is .Net 3.5 or later (Visual Studio 2008 or later)
In my opinion, jQuery has the best AJAX functionality and is easy to learn and use. It's got great documentation and there are lots of tutorials and examples -- I love it.

Is there a tool to get the ViewState byte count for any of the major browsers?

I am looking for a tool to give me a byte count of ViewState after each postback (full or partial) to make sure that I'm not keeping any controls' states around unnecessarily. Is there a tool out there?
If you use fiddler, I recommend you this extension
http://blogs.msdn.com/nexpert/
It gives you information about viewstate size and many other performance items.
If you're not using fiddler... what are waiting for??? :-)
If you add the attribute Trace="true" to your page, it will output debug information including the view state when you browse the site. No plugin is required.
For Internet Explorer there is a plugin called Web Development Helper that shows view state information.
Yes, and it's called Viewstate Size.
https://addons.mozilla.org/en-US/firefox/addon/5956/

ASP .Net Output Caching and Ajax Control toolkit

I'd like to know if there's a special way of implementing output caching and using a control from the ajax control toolkit. I keep getting a javascript error on a page with output caching and a tab control that says: ajaxtoolkit (my assembly prefix) is undefined.
This is the directive I added:
<%# OutputCache Duration="3600" VaryByParam="none" %>
Microsoft does not support output
caching in combination with
ScriptControls, Extenders, or
ScriptManagerProxies that need
ScriptReferences. A workaround to the
issue is to include the script
references these resources require on
the main script manager, outside the
output cached control.
More info here
Since the output caching cannot be combined with the generated scripts by the AJAX framework yet (hopefully in a future version some similar behavior will be available crossing fingers), other type of optimization approach has to be made like replacing the ScriptManager for the ToolScriptManager.
http://blog.creonfx.com/performance/howto-optimize-rendering-speed-of-aspnet-ajax-websites

Struts 2 & Dojo files are too heavy and affect site's performance.. Any remedies?

Well.. we've developed a j2ee application using struts2 ajax capabilities. We find that the dojo implementation is quite slow. We did the following things:
1. Custom build of the dojo library. (increased dojo.js from 240kb to 350kb)
2. Took all the static stuff out of the struts jar and kept it outside.
The performance was significantly improved. But still it is quite heavy as you can guess with 350kb size..
Is struts2 ajax supposed to be this heavy? or is there any lighter implementation available?
Edit: I used Firebug and YSlow with my application. Couple of changes that improved my situation hugely are mentioned below:
Custom build of dojo (reduced the number of I/Os)
Move the static files out of Struts jar (helped a great deal)
tune your server to gzip the response (reduced the response size to 1/3)
Reduce number of images on your site.(this is obvious)
Will keep updating on further changes..
First of all check that you did everything on the server to facilitate caching (e.g., setting right HTTP headers, compression, server-side caching, upstream caches, and so on). See Improving performance… for more details.
The goal is to reduce I/O as much as possible — use Firebug or any other network traffic monitoring tool to see how much is sent back and forth. Try to minimize the number of I/O requests and the total number of bytes.
Don't forget that it applies to your dynamic data too — choose efficient formats, bundle several related requests together, remove all deadwood that is getting sent over and over unchanged.
If the custom build and server-side tweaks didn't help, consider restructuring your web app to be more light-weight. Examples:
Evaluate the splash screen technique discussed in the link above.
If you use a lot of different form widgets, see if it is really necessary, and fall back on regular DOM elements like "input", "button", "textarea", "select".
The same goes for layout widgets. See if simple CSS can help you out.
Evaluate building Dojo in layers instead of one monolithic dojo.js so only the necessary subset is loaded by web pages. See details in The Package System and Custom Builds.
Building web applications with Dojo for a living for last 2 years I still didn't see the one that cannot be optimized properly until it is fully accepted and perceived by end users as "fast", "nimble", and "light-weight".
Make sure you follow this faq first:
http://struts.apache.org/2.x/docs/performance-tuning.html
I usually re-write my own theme instead of using the struts2 ajax theme which has dojo built in. This way I can use whatever toolkit I want to use (jQuery). I saw the biggest performance improvements when I copied the templates folder from the jar to the root web directory for the webapp.
Last I checked, struts was shipping a release of Dojo (0.4) that's going on 2 years old. Dojo did a rewrite for version 0.9/1.0 that had significant performance gains and reduced code size. You should make sure you're running a recent version of Dojo (current version is 1.2.3) and use the build and tips from Eugene, above.

Resources