0

I'm developing and ASP.Net MVC 3 website.

I've to give an access on some function through a webservice.

  1. Is there a way to directly do this in Asp:net MVC 3 ? (e.g. with a special controler? where all my action would be an available action of the controller)
  2. If yes, is this recommend?
  3. Otherwise I will create a WCF service, but is this possible and/or recommanded to host it in an Asp.Net MVC application? I need to have the webservice accessible on the same domain/port than the main website. How can I do this?

Thank you very much

3
  • 1
    Take a look at WebApi asp.net/web-api Commented Sep 27, 2012 at 14:26
  • What about your clients for your service? JS clients? and why you want the service to run in the same domain? Commented Sep 27, 2012 at 15:06
  • @Mark: .Net and Java application. For IT reasons Commented Sep 27, 2012 at 15:13

1 Answer 1

3

A) Yes, there is, this CodeProject outlines a RESTful service with MVC 3. Although, the nicest way to do that is with Web API, which is part of MVC4.

B) Yes it is a good way to create a RESTful service with MVC. The question of whether you need a RESTful service depends on the project.

C) I've never seen that, and while it may be possible I'd prefer to keep the two in separate projects and app pools.

Sign up to request clarification or add additional context in comments.

5 Comments

Web API seems to be what I'm searching, but just to be sure: can we offer a regular webservice to external application(may be an application that isn't in .Net, ...) and not something that has to be interpreted by a .Net library?
That is correct. You can create RESTful services with WebAPI that can be consumed by none-.NET clients.
WebAPI is really nice, so if you have that option go for it.
@JoeR Do you have reasons that says why it's so nice. Actually I'm kind of frustrated to see an additional controller in MVC stack and I hope you aware that we can create a RESTful service using the default controller itself. I see it's more kind of additional learning and that is one of main problem in software development instead of learning new things we spent time on learning how to do the samething in different ways.
Hello Mark. The learning curve for Web API is very small for someone used to creating services in MVC3. Web API is obviously designed with services in mind, so it's more intuitive and clean. I hear what you're saying about all the changes to the .NET platform, but there have been huge improvements. I've recently had to do a bit of work on WebForms again and cannot believe we put up with them for so long! :-) I'm always happy to go back to MVC.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.