Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do standard webservices (asmx) work with MVC?

I have just tried adding a WebService (asmx based) from a WebForms project to a new MVC project. I cant seem to get to the asmx webservice in IE?

In MVC should this work the same, I have the service in a Services folder, should this be in a View or should this asmx work outside the 'MVC' routing?

Update:

I set up the WebService initially dropping in the .asmx file onto a test server, recently setup with .Net 4.0 for the VS2010 MVC 2 project. (Windows Server 2003 IIS 6)

The same Webservice is on a development (VS 2010) machine is viewable? Any ideas on the difference, possibly a setup issue?

like image 512
Mark Redman Avatar asked Feb 22 '10 15:02

Mark Redman


3 Answers

According to Scott Hanselman, the request is by default not handled by the ASP.NET MVC routing mechanism:

Why doesn't ASP.NET MVC grab the request? Two reasons. First, there's an option on RouteCollection called RouteExistingFiles. It's set to false by default which causes ASP.NET MVC to automatically skip routing when a file exists on disk. (Source)

Which would indicate that there is a problem somewhere else.

like image 115
Anders Fjeldstad Avatar answered Sep 20 '22 21:09

Anders Fjeldstad


If you want the quick/easy/dirty solution, pull the ASMX Service out of the MVC Routing somehow.

If you want to do things the better way, pull the logic out of the ASMX service and create a new page for it in your MVC application. You can then implement the logic in your Controller and allow the View to handle returning the SOAP message (or you could go with JSON depending on who is consuming the service).

like image 36
Justin Niessner Avatar answered Sep 19 '22 21:09

Justin Niessner


Answering my own Question..

I can see WCF services when creating a basic service (and cannot see asmx services)

Since WCF is considered the way to go anyway, I am doing that.

I didnt persue getting the asmx to work.

like image 21
Mark Redman Avatar answered Sep 20 '22 21:09

Mark Redman