Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i call [WebMethod] which is defined in user control?

I am working in Asp.Net using C# and I have a [WebMethod] defined in a User Control. I don't want to use a web service.

How can I call a method with an [WebMethod] attribute? I want to call it from a jQuery (Ajax) request.

like image 465
Rana Imtiaz Avatar asked Dec 01 '25 06:12

Rana Imtiaz


1 Answers

You really should reconsider using a service if your goal is to centralize shared functionality.

ASMX services don't have any of the configuration burden that WCF services do (which is often what comes to mind when someone mentions "web service" now). If you use a simple ASMX "ScriptService", the code, development, configuration, etc will be nearly identical to what you're doing in ASPX files now, just centralized. ASMX ScriptServices and ASPX page methods are so similar that they literally share most of the same underlying backend code.

like image 169
Dave Ward Avatar answered Dec 02 '25 19:12

Dave Ward



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!