As stated in MSDN
Attaching the WebMethod attribute to a Public method indicates that you want the method exposed as part of the XML Web service
If I get it right, this is not what you want to do, as this practice is oriented in exposing the functionality to outside consumers.
I would suggest three ways to avoid repeating the common functionality in ASP.NET.
The first way would be to use page inheritance. In ASP.NET a page a subclass of class System.Web.UI.Page
. Therefore, you could create a BasePage
having all the common functionality, and your pages could inherit it, inheritting the respective functionality.
The second way, would be to use the decorator design pattern. This design pattern would allow you to move common functionality in one place and decorating specific pages with it. It is not the simplest thing to do and therefore it would not be my first suggestion.
The third way is using an HTTPHandler. This and this MSDN posts could help you understand what we are talking about. This microsoft tutorial could guide you on how to do it.
Hope I helped!