Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP 404 error while invoking a local webservice in .NET MVC4

I am trying to learn webservices in .NET mvc4. I tried creating a new Internet application and adding a Web service (asmx) to the project.

By default, the VS adds a "HelloWorld" Webservice. When I try to run it in the browser, I do get the list of operations, service description(WSDL) and the details of the HellowWorld operation. However, when I try invoking the webservice, it gives the following error :

Server Error in '/' Application.

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

I might be missing some basic step/setting I guess. Could some body help please. Thanks.

like image 887
saurabh Avatar asked Jun 12 '13 03:06

saurabh


1 Answers

I got the answer from one of my colleagues :) .

When we invoke the service, the MVC tries to resolve the path as specified in RegisterRoutes. Hence it tries to find a controller with that name and a method with the name same as that of the operation inside that controller. The resolution, ignore the paths with .asmx extension. You can do that by adding the following line in RouteConfig.cs :

routes.IgnoreRoute("{*x}", new { x = @".*\.asmx(/.*)?" }); 

and it worked. Thanks.

like image 165
saurabh Avatar answered Nov 07 '22 08:11

saurabh