开发者

Is It Performance Rich to use Web Services called via jquery ajax method in ASP.Net?

开发者 https://www.devze.com 2023-02-19 02:45 出处:网络
I have seen tha开发者_运维百科t ASP .Net Code Behind files are really slow. I have used local web services which I call from jquery ajax function and they are fast. But I am still confused? Should i d

I have seen tha开发者_运维百科t ASP .Net Code Behind files are really slow. I have used local web services which I call from jquery ajax function and they are fast. But I am still confused? Should i display dynamic data from code behind or web services?

I let my web service return a JSON Object and I assign relevant elements from that JSON object to different html elements like (image, div etc.)


You need to weigh several things..

If you are dealing with a low-traffic, internal web application, perhaps server-side postbacks are the way to go. Often you'll find that there's less code you'll have to write in this case.

If you are working on an external, public, high-traffic web application, perhaps AJAX is the way to go. That way you avoid posting back entire ViewState and running through the full page lifecycle. This may result in more front-end code, but is less load on the web server.

Keep in mind that client-side data binding is a very viable solution these days, with the help of such things as jQuery Templates. So that helps bind data returned from AJAX calls to tables and other elements.

As far as web services go, they are great for when you're sharing data/functionality between different systems. If you don't foresee doing that for this particular application, then perhaps there's no need to over-engineer it - keep it simple with either MVC and Action methods that support AJAX calls out of the box, or get familiar with PageMethods.

I'm sure there are other pros/cons I haven't mentioned, but this is the first thing that came to mind.


ASP.NET classic life cycle and postback is the base of Microsoft Click&Go philosophy. It is not designed to be fast even if it suits in most cases.

AJAX plus Web Services architecture is good way to improve server performances and dynamicity. It may not improve client performances, may increase the network load if bad designed and complicate a website architecture.

Another possible orientation is ASP.NET MVC, where old life cycle and postback is ancient history.

Like Kon said, mixity is probably the best way at the moment : MVC+AJAX or ASP.NET+AJAX where classic client<->server requests are used for common functionnalities and AJAX requests brings dynamicity with small requests for friendly functionnalities.

Note that most users on the planet are using Internet Explorer who have the worst javascript engine on the planet ;)

0

精彩评论

暂无评论...
验证码 换一张
取 消