Control Methods tries to bring ASP.NET AJAX Page Methods to UserControls to allow individual controls to define their own static WebMethods for AJAX calls which allows developers to group control related logic in the code-behind as is possible with Page Methods.
To allow UserControls to contains static WebMethods that can be accessed by client-side scripts in a manner similar to that of
Unfortunately all of the implementation details that facilitate Page Methods are internal classes and methods. In lieu of reinventing the wheel this solution has, for the time being, resorted to using Reflection to access and invoke these hidden members. As
a result of this design decision, some security considerations must be made. This is especially important when considering production environments and shared hosts.
There are two methods of accessing static WebMethod definitions within UserControls provided:
- ControlMethodModule - This module allows Control Methods to be called in a manner almost identical to Page Methods. It is best used in an Assembly registered in the Global Assembly Cache (GAC) which allows the web application to be run without need
for Full Trust (most systems give assemblies in the GAC Full Trust by default).
- ControlMethod.ashx - This handler allows control methods to be called in a manner
similar to Page Methods but no HttpModule is called for all requests. Instead only requests to ControlMethod.ashx will even consider the possibility of a JSON request. _This approach requires either Full Trust or a custom trust configuration allowing
Reflection of non-public members.
This will be changing soon; for more details refer to the Plans section below.
Control methods was born of curiosity, but is now being tested in production environments and
jQuery MicroAjax for .NET
, a new framework for organizing and simplifying Ajax applications in ASP.NET, is building on the functionality exposed by Control Methods. As a result maintenance and development are becoming
more dependable and improvements will be coming soon. After researching the request life-cycle of Page Methods and the security model of ASP.NET, improvements to the implementation are now in development.
Support and Legalities
This has been tested as working with ASP.NET AJAX 3.5 and 4.0 on 32 and 64-bit editions of IIS 6 and 7 (Visual Studio 2008 SP 1's built-in web server, however, does not work). Your mileage may vary. The current implementation depends on Reflection of internal
members of Microsoft's ASP.NET AJAX libraries and, therefore, cannot guarantee stability in future versions of the Framework. While it is very unlikely any breaking changes will be made in any updates to .NET Framework v3.5 or 4.0, it is technically possible
for this code to stop working at any time.
Control Methods for ASP.NET AJAX is provided "as is" with no guarantees or warranties express or implied, including implied warranties of fitness for a particular purpose, merchantability, and non-infringement.
Control Methods for ASP.NET AJAX is a project created and maintained by the Extensible Development Solutions Group. "ExtenDev" is a small group of engineers dedicated to making elegant and extensible libraries and frameworks as well as researching
extensibility techniques and technologies.