在global中加入下句代码
routes.IgnoreRoute("ajaxpro/{*pathInfo}");
原帖:
Ajax.NET is the first Ajax library for the .NET framework. Up until the day ASP .NET 3.5 was released, there was nothing quite like it. In ASP .NET 2.0, the UpdatePanel was introduced as a way to enable partial rendering on ASP .NET pages. UpdatePanels are quick to implement. However, the downside of it is its inefficiency. The viewstate of the page gets posted back as well! This gives you a bloated asynchronous request and basically defeats the purpose.
It is during times like this that Ajax .NET looks very attractive. With support for PageMethods in ASP .NET 2.0 (in Ajax.NET the attribute tag [AjaxMethod] is used instead), JSON serializers, built-in caching, javascript compression, synchronous calls, etc. what is there not to like about Ajax .NET. You could even return DataTables, DataSets, enums, and other custom structures to the client-side directly.
It is also an open source project and the code is available here. Unfortunately, development of Ajax.NET has "stopped", and the creator himself has suggested the use of the Ajax features provided by ASP .NET 3.5. However, the project itself is still being updated once in awhile. I guess it's hard to completely let go of a project that you've been working on for a long time. People just get attached to their code. Well... I know I do.
Anyway, I have been using Ajax.NET since .NET 2.0, as well as since .NET 3.5. I haven't found a good reason to switch and it even runs under ASP .NET MVC and I reckon it is still better than using Ajax.ActionLink(). Unless of course, there's some easier method that I do not know of then please feel free to enlighten me anytime. Most of my Ajax use centers around requesting data from the server asynchronously and then using javascript to update the DOM.
Installing Ajax.NET
To include Ajax.NET into your MVC project, follow the following steps:
12 <sectionGroup name="ajaxNet">
13 <section name="ajaxSettings" type="AjaxPro.AjaxSettingsSectionHandler,AjaxPro.2" requirePermission="false" restartOnExternalChanges="true"/>
14 </sectionGroup>
Under <configuration>
30 <ajaxNet>
31 <ajaxSettings>
32 <token enabled="true" sitePassword="notmypassword" />
33 </ajaxSettings>
34 </ajaxNet>
Under <httpHandlers>
107 <add verb="*" path="/ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/>
30 routes.IgnoreRoute("ajaxpro/{*pathInfo}");
Using Ajax.NET
To be able to call your class methods on the client-side, you will need to add the [AjaxPro.AjaxMethod] attribute to the method. The AjaxMethod attribute can be used on any methods in any classes and is not limited to methods in the code-behind of your webpages. You will then need to inform AjaxPro parse the class containing your marked method to generate proxy classes for the client-side. This usually is done via the method
AjaxPro.Utility.RegisterTypeForAjax(Type t)
at the Page class. The other method is to directlypoint AjaxPro to the location by adding the script tag
<script type="text/javascript" src="/ajaxpro/className,assemblyName.ashx"></script>
The className MUST include it's namespace. Basically the above allows AjaxPro to find the method through reflection in the assembly to generate the appropriate proxy classes.
As there is not really a concept of pages in ASP .NET MVC, the second method is used and you will additionally need to add the following script tags (these are normally generated when you use RegisterTypeForAjax)
<script type="text/javascript" src="/ajaxpro/prototype.ashx"></script>
<script type="text/javascript" src="/ajaxpro/core.ashx"></script>
<script type="text/javascript" src="/ajaxpro/converter.ashx"></script>
原帖地址:http://my6solutions.com/post/2009/03/09/Running-AjaxNET-Professional-under-ASP-NET-MVC.aspx