ASP.NET MVC and Ajax slow?
I've just started out trying MVC 2 and Ajax, and I'm wondering if I'm doing something wrong, because I was under the impression that Ajax would make changes in a webpage very fast. The example I have is with the Ajax actionlink:
<div>
<%: Ajax.ActionLink("Dita", "AjaxView", new AjaxOptions { UpdateTargetId = "myDiv" })%>
</div>
<div id="myDiv">
Change this text</div>
And the Action method:
public ActionResult AjaxView(string id)
{
return Content("Text changed!"); ;
}
This is a rather short simple text string, and still it takes about 1-2 seconds before the text shows up. Maybe ajax isn't supposed to do what I thought it would, but I was thinking I could use it for instant previews of text and images sort of like a rollover开发者_如何学JAVA function (by the way I was wondering if the actionlink can be set to invoke the action method on mouseover rather than click?)
Is it normal that it is this slow or am I missing something?
It might be an IPv6 DNS resolution issue with FF and Chrome when working with localhost
. Fixes described here:
Firefox and Chrome slow on localhost; known fix doesn't work on Windows 7
and here
https://superuser.com/questions/174715/is-there-a-way-to-disable-ipv6-in-googles-chrome
I would try in IE and Opera first to check if it works faster.
Note: if that's actually the problem, this has nothing to do with AJAX.
I think you've misunderstood slightly.. There is nothing about AJAX that will necessarily make your Web application faster. What AJAX does is to only load the information you need instead of loading the entire page over again. That way you can make subtle changes to the page you're viewing without having to refresh the entire page.
The point being - when you call AjaxView it still has to do a call back to the server which will take time no matter what you do. The reason why this action is slow might rely on different factors; - Your server might be busy doing something else, hence consuming resources - You just built the assembly, making the call slower the first time around
精彩评论