Questions tagged [webmethod]

WebMethod is an attribute that is marked to indicate that a function (usually in .NET) in a web service is exposed to the consumers of the web service.

The WebMethod attribute is attached to a public method (cannot be attached to a private/protected) that you want the method exposed as part of the .NET Web service. It is also used to further configure the behavior of the method by passing additional attributes. Check out the MSDN link for more information, How to: Use the WebMethod Attribute.

1317 questions
7
votes
1 answer

.NET: How to deprecate a WebMethod?

In .NET, is there a standard way to indicate that a web service method has been deprecated? To clarify, by 'web service method', I mean a method that has been decorated with the [WebMethod] attribute. Is standard practice to just use the…
Dan Esparza
  • 28,047
  • 29
  • 99
  • 127
7
votes
1 answer

ajax send FormData c# WebMethod

I have a form with a File Input and one Button, when I press the button the file should go to the server side. When I send a file to the server the ajax response is success, never stop in the c# webmethod breakpoint that I use. What I am doing…
Ivan Arias
  • 71
  • 1
  • 3
7
votes
1 answer

unexpected 's' in postman on sending Webmethod

Integrating a payment Checkout Stripe. Used JavaScript Stripe handler, to apply Stripe charge on the transaction. After charging the customer, it returns token. Using this token we can proceed for Actual payment. And here is the AJAX call to…
Vikrant
  • 4,920
  • 17
  • 48
  • 72
7
votes
1 answer

Confused by TaskScheduler and SynchronizationContext for sync-on-async, can't control the sync context?

The Issue I have an ASP.NET 4.0 WebForms page with a simple web-service WebMethod. This method is serving as a synchronous wrapper to asynchronous / TPL code. The problem I'm facing, is that the inner Task sometimes has a null SynchronizationContext…
7
votes
1 answer

What is the difference between ashx, asmx, axd + cs(handler), webmethod(in aspx) and async methods in asp.net framework 4.5?

I need to know the technical difference of those files. Which one is the best option? When and why should we use it? I need a human answer, not the MSDN links.
6
votes
4 answers

WebMethod not being called

I am passing a javascript variable containing a string to the server via jquery.ajax. Although the "success" condition is called, the server-side WebMethod is never called. Client: $.ajax({ type: "post", url:…
Seraph812
  • 397
  • 3
  • 7
  • 17
6
votes
4 answers

How to return error from webmethod?

How does one return an error in an aspx page method decorated with WebMethod? Sample Code $.ajax({ type: "POST", url: "./Default.aspx/GetData", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", …
Thomas
  • 33,544
  • 126
  • 357
  • 626
6
votes
4 answers

405: Method Not Allowed

EDIT: Summary: It seems that my web app can be accessed by anyone (only firefox or chrome) and by me using my main computer. If i try to access http://luiscarlosch.com/WebFormClean.aspx from any other of my LAN it gets a 405 error I can perfectly…
Luis Carlos Chavarría
  • 3,861
  • 2
  • 25
  • 26
6
votes
2 answers

HttpContext.Current.Session in a Shared method isn't persisting changes

I'm using some WebMethods in a System.Web.UI.Page to handle some ajax requests, and I'm trying to store an object in the session to retain information across several ajax requests and even after leaving the page and returning. I'm accessing the…
Mar
  • 7,765
  • 9
  • 48
  • 82
6
votes
2 answers

Is there a way to return DateTime in ISO format from a asp .net web method instead of JSON format?

Currently the web methods or most of the methods in classic asp .net serializes using system.web.script.serialization.javascriptserializer class and this returns the javascript object's datetime members with values such as "/Date(number of…
Muthu
  • 2,675
  • 4
  • 28
  • 34
6
votes
1 answer

Authentication failed error when calling web method using $.ajax

When I make a JQuery call, I get an Authentication failed response: { Message: "Authentication failed.", StackTrace: null, ExceptionType: "System.InvalidOperationException" } jQuery call: $(document).ready(function () { //Handle…
Aaz
  • 101
  • 1
  • 1
  • 5
6
votes
2 answers

How to pass json string to webmethod c# ASP.NET

Im trying to stringify a javascript object and then pass the string as a parameter to a WebMethod in Code Behind. I can't get it to work as I get a Internal Server Error of 500 and the stacktrace says that value is missing for parameter. Here is the…
6
votes
2 answers

$.ajax Returning HTML of the page instead of results

I wrote a simple webmethod that I call on the client side to check if a value exists in the database on text change. It works fine locally, but when I move it to our Development environment it returns the entire HTML of the page in the response. …
A Kimmel
  • 176
  • 1
  • 6
6
votes
5 answers

ASP .NET: Cannot call Page WebMethod using jQuery

I created a WebMethod in the code-behind file of my page as such: [System.Web.Services.WebMethod()] public static string Test() { return "TEST"; } I created the following HTML page to test it out:
John
  • 9,254
  • 12
  • 54
  • 75
6
votes
2 answers

LoadControl, usercontrol in WebMethod

I am trying to send an email through a WebMethod Below is the code I typically use on a regular post back [WebMethod] public static void SendEmail(string name, string phone, string emailaddress, string interest, string comments) { var control =…
Jon Harding
  • 4,928
  • 13
  • 51
  • 96
1 2
3
87 88