tarun satepuri
tarun satepuri

Reputation: 23

How to call Javascript method in webservice using asp.net

In Webservice is it possible to call javascript function. [Or] In Webservice is it possible to redirect page. I have used this(System.Web.HttpContext.Current.Response.Redirect("~/Error.aspx");), But, i didn't find any sol for it. Please, reply as soon as possible.

Upvotes: 0

Views: 215

Answers (1)

Satinder singh
Satinder singh

Reputation: 10218

You can't call JS function from WebMethod.

But there is a trick you can set your Webmethod response in such way that on the success it returns some parameter or your URL which you want to redirect.

Something like

success: function(response){
  var r=response.d;
  window.location.href = r;
} 

Or

You need to build a SOAP extension.

Application_Error never fires for WebService

The reason for this is that the HTTP handler for XML Web services consumes any exception that occurs while an XML Web service is executing and turns it into a SOAP fault prior to the Application_Error event is called. To achieve exception handling you need to write a custom SOAP extension or HTTPModule.

Check this links:

  1. Throwing Better .NET Exceptions with SOAP and HTTP
  2. User-Friendly ASP.NET Exception Handling

Upvotes: 1

Related Questions