开发者

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:开发者_如何学Go

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?


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.


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).


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.


YES it does, I created the base project then I right clicked on the project name and added a webservice file with the demo of hello world in it. If you view that file in the browser it works fine.


It should work outside the MVC-routing. Just creating a folder with the asmx-files should be sufficiant. I've got a 'webservices' folder inside my project, and it works great! No need to set the routing to ignore the path, the file does exists on the server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜