views:

64

answers:

2

I'm very new to the whole Ajax/Asp.Net stuff so...

I know that there are at least a few different ways of implementing the server-side of an Ajax enabled Asp.Net site.

One way is to add static methods to your aspx page's code-behind and mark them with the WebMethod attribute.

Another way is to use a separate ASMX web service file (which I don't know anything about :) ).

What are the most commonly used options for implementing the server-side? What advantages and drawbacks does each one have? And how does each one fare from a security and session perspective? (Making sure the server knows which session the Ajax request is from and ensuring only logged-in users are responded to?)

+1  A: 

Typically I like to use jQuery to make the requests to .ashx page that is responsible for reading the data and passing back the JSON to the page to deal with. It sounds like the other options you suggested are pretty complicated by comparison.

Jon
The .ashx is much simpler to use
mcjabberz
A: 

The two most commonly used options are

  1. Microsoft ASP.Net AJAX
  2. JQuery partnered with webservices or request handlers (like Jon's answer)

Microsoft's ASP.Net AJAX is a framework that revolves around two server controls - the ScriptManager and the UpdatePanel. It's a bit more heavyweight than other options, but it's certainly a simple way of ajaxifying your site. You simply use an UpdatePanel to surround the portion of the page that you wish to be asynchronous, and all your controls that do postbacks (buttons, links, etc.) automatically become asynchronous requests that will only update that portion of the page. No coding or anything.

If you do plan on using the webservice route, ASMX is not the way to go - it's basically a "legacy" technology at this point and you should consider using WCF services instead.

womp