开发者

How do you place a web services aside with your ASP.NET MVC web application

I currentl开发者_C百科y have a web application written by ASP.NET MVC. Now I want to add a web service so that some people can easily build application upon it. Shall I just create the asmx in the MVC Web project or create another project referencing to the Model project? And what's the pros and cons?

Thanks in advance!


Easy decision - if your MVC Web project depends on the web service at all, keep it in the MVC Web project. If not, create a separate project for the web service with reference to your model.

Keeping projects seperate allows people to read and understand your code more effectively. If your service makes use of your model, but is not part of that model, than it should definitely be a standalone project with reference to the model. This is clean design.


for my opinion I would do something like this in my solution

solution.Model           -- the model that reflects your db,
solution.Repository     
solution.MVC             -- your model will be the refined Model, referencing the solution.Model
solution.Test
solution.WebService      -- referencing solution.Model

I keep my Model outside my MVC Web application and just put the refined ViewModels in my MVC Model folder. I don't know much about pro's and con's but this is just a better way of doing it for me.

Doing this, you can use your Model anyway you want. Maybe you want to use it for WebService as what you ask. Or for another Application. You just reference your Model project to other projects that you need them.


I would look for Odata -> WCF Data Services formaly know as "Astoria". If you are using for example linq-to-sql or EF you can make your data in a restful manner availale and provide a basic api... You can define your endpoint like you do in WCF because the underlying service is based on WCF. And I would use a different namespace...

Website http://msdn.microsoft.com/en-us/data/bb931106.aspx

Beginners guide with videos http://msdn.microsoft.com/en-us/data/ee720180.aspx

open data format http://www.odata.org/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜