½«jQueryÓ¦ÓÃÓÚAsp.net Ajaxʱ£¬Ó¦±ÜÃâµÄ3¸ö´íÎó
3 mistakes to avoid when using jQuery with ASP.NET AJAX
AJAX, ASP.NET, JavaScript, jQuery By Dave Ward on June 5th, 2008
Over the past few weeks, I think I have definitely embodied Jeff Atwood’s claim that we’re all amateurs, learning together. Despite my best efforts to thoroughly test before posting, a few problems slipped through in my recent posts about using jQuery to consume ASP.NET JSON serialized web services and using jQuery to call ASP.NET AJAX page methods.
On the bright side, your great feedback in both posts’ comments has reinforced the fact that some of the best content on my blog is the part that you write.
In this post, I’m going to detail three of the problems that were discovered as a result of those previous two posts:
An extra requirement when making a read-only request to IIS6+.
An oddity in Internet Explorer 7’s XmlHttpRequest class.
A common mistake when passing JSON parameters through jQuery.
Finally, I’ll suggest what I now believe to be a best practice usage, taking all of these issues into account.
Security requirements when POSTing to IIS
This error message was the most common problem that was reported:
Length Required
The underlying issue is that most installations of IIS6+ require a content-length be provided with all POST requests, even if there is no content (POST data).
The content-length for a request with no data should be 0, but jQuery doesn’t set that header automatically unless there is a data parameter. Since ASP.NET AJAX’s JSON serialized services require a POST request, this becomes a stumbling block for read-only requests.
The easiest way I’ve found to work around this is to use an empty JSON object as a parameter on read-only requests. For example, if you were calling a page method:
$.ajax({
type: "POST",
url: "PageMethod.aspx/PageMethodName",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json"
});
This will c
Ïà¹ØÎĵµ£º
3¸öÎļþ
code ÀàÎļþ
using System;
using System.Text;
namespace ConcreteMIS.Common.Chinese
{
/// <summary>
/// ºº×ÖÆ´ÒôÉùĸ¼ÆËãÀà
/// Write by WangZhenlong at 2003/11/29
/// </summary>
......
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Sy ......
ÕâÀïÎÒÃǽ«½éÉÜASP.NET»º´æµÄ¹¤×÷ÔÀí£¬°üÀ¨¼òµ¥µÄ¶¨Ò壬Êý¾Ý»º´æÒÔ¼°»º´æµÄÉèÖõȵÈÄÚÈÝ¡£Ï£Íû±¾ÎÄÄܶԴó¼Ò½ñºóµÄ¹¤×÷ÓÐËù°ïÖú¡£
ÈçºÎ±ÜÃâASP.NET»º´æÕ¼ÓÃϵͳ×ÊÔ´
ÔÙ̸ASP.NET»º´æ»úÖÆ£º¿ª·¢Ð§ÂÊÓëÓÅ»¯µÄ..
ASP.NET»º´æ»úÖÆ»ù´¡¸ÅÄî
ASP.NET»º´æÊý¾ÝÌí¼Ó·½·¨Ò»ÀÀ
ASP.NET»º´æÊý¾Ý¼¼ÇÉÈýÔò
½éÉÜ
»º´æÊÇÔÚÄÚ´æ´ ......
ÒëÎÄÔÎĵØÖ·
http://www.cnblogs.com/hl13571/archive/2008/01/28/1056671.html
Ó¢ÎÄÔÎĵØÖ·
Understanding Single Sign-On in ASP.NET 2.0
Àí½âASP.NET 2.0Öеĵ¥µãµÇ¼
Published: 16 Jan 2008
ÕªÒª
ÔÚÕâƪÎÄÕÂÖУ¬MasoudÌÖÂÛÁËÓ¦ÓÃASP.NETÖÐͳһÉí·ÝÑé֤ģÐͽøÐпçÓ¦ÓóÌÐòÑéÖ¤µÄÎÊÌ⣬°üÀ¨£ºMembership Prov ......
JSON Serialization and Deserialization in ASP.Net
I was looking around for a simple example which would just do an object serialization to a JSON format, and then deserializing back to the original object. I found few examples on MSDN, but did seem to be too long ......