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.
-
Are you mistaken WebApplication for WebService?Rohit Vipin Mathews– Rohit Vipin Mathews2015-06-02 06:46:29 +00:00Commented Jun 2, 2015 at 6:46
-
In Web service only. Rohittarun satepuri– tarun satepuri2015-06-02 07:06:35 +00:00Commented Jun 2, 2015 at 7:06
-
How to create a global exception handler for a Web Servicetarun satepuri– tarun satepuri2015-06-02 07:13:27 +00:00Commented Jun 2, 2015 at 7:13
-
In your global.asax, return the corresponding HTTP error code with message.Rohit Vipin Mathews– Rohit Vipin Mathews2015-06-02 07:48:56 +00:00Commented Jun 2, 2015 at 7:48
-
When we get any error in web service Catch it is not navigating to global.ascx.cs pagetarun satepuri– tarun satepuri2015-06-02 07:52:14 +00:00Commented Jun 2, 2015 at 7:52
1 Answer
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: