Difference between WebApi controllers and WCF WebAPI [duplicate] - asp.net-mvc

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
What's the difference between WCF Web API and ASP.NET Web API
I've started looking at the new features of MVC 4. One of the notable new features is ApiControllers.
I still cannot understand why to use this rather than WCF WebAPI? Is that because Microsoft's trying to fadeout WCF WebAPI, or gather all tool sets in a single place which is an MVC 4 project?

Please take a look at this.

Related

Is it good practice to use ASP.NET MVC without a View? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
We're planning to build a web service to retrieve and send data to an external application.
Someone suggested we use the ASP.NET MVC project. Thing is, we won't have a view. All we're doing is a query and returning the output to the caller. I questioned the use of this project.
He responded that you don't need a view to utilize a MVC project. He added that we can take advantage of the URL routing feature. However, I'm still skeptical.
Is there any reason to choose ASP.NET MVC over a Web API considering we won't utilize the View?
You aren't required to use views (or models for that matter) in MVC. In this case both MVC or Web API would work equally well. There is no advantage of one over the other if you are not using views.
Do note that in ASP.NET Core there is now no difference at all - there is only 1 framework to use and it can be used with or without views.
If you are really want to make some service it's most probably helpful when you use web API. True, it's not necessary to have views in asp.net MVC and also routing is working more similar in both.
The thing is, if you need to authenticate the calls there is little difference how we authenticate calls. Normally web API has come with token-based authentication rather than using cookies use in asp.net MVC.
For your current requirement, the best solution is WebAPI.
You should use MVC controller if you are going return a view. You can return data also from MVC Controller, but is better to user WebAPI controller if you wish to return only data(you can use it like a HTTP service).
The Advantage of using WebAPI is I can say it is a light weight. Hence you can go with WebAPI

Website development - Which tools and languages? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
for a project I will need to develop a website. The problem is: This is the first time for me.
I am currently planning and drawing the outlines and also trying to find out which technique will suit the project best and how to approach this task.
The website should retrieve data from an API by using RESTful HTTP-Commands and present the results to the registered user.
My programming experience so far is mainly C++ and some C#/.NET which I used for the creating the API.
So, which language and script do you think would suit best? I have looked into ASP.NET MVC a bit because of my previous experience with .NET. Is that a proper choice?
Apart from
that, I would prefer a graphical designer for the HTML-coding. What tools would you use? I looked into Google Web Designer, but I was not quite persuaded. What would you recommend?
Thanks in advance!
Eteokles
I agree with Sami, if you have basic knowledge in CSharp/.Net it is not a bad idea to use ASP.NET MVC/API to setup your project. But you should bear platform dependence in mind if you are not using .NET Core, which is actually in Version 1.0.0 RC 2. So if you use ASP.NET 4 you will have to use a Microsoft Server to deploy your application. If that is no problem for you, then I would recommend to have a look at Microsoft Virtual Academy. Developing ASP.NET applications with Visual Studio is a pleasure, you have great debugging tools and you can create Unit Tests to test your application.
Unfortunately there is nothing like a graphical designer for your HTML frontend in Visual Studio. But if you are using Bootstrap you can reach your design goals really fast. Also Bootstrap is "mobile first" which means, that even if a user accesses your Website over a mobile device (Tablet, Smartphone) the site will look great. The basic ASP.NET 4 MVC template comes with a Bootstrap layout, you could build upon.
If you want to enable users of your application to create user accounts you can choose the ASP.NET MVC template with "individual user account" ASP.NET Identity
In conclusion I want to provide you another link where ASP.NET is compared to another very popular and easy to learn language for developing websites PHP vs. ASP.NET. I would recommend ASP.NET after using PHP for years, because thinks like asynchronous programming and using Entity-Framework to handle your database needs.
I would also recommend you to do further reading on the pros and cons of different tools and languages and after you have a general overview over the available solutions you should compare which language and which tools match your application needs most. Happy coding.
Based on your experience/knowledge, ASP.Net, MVC and API seems a good to go option. You might need to understand Javascript/jQuery and JSON to communicate with API. It's pretty simple like:
$.getJSON("http://localhost/api/products", function(result){
$.each(result, function(i, field){
$("div").append(field + " ");
});
})
For UI, Bootstrap is always a good choice and easily get your layout at
Layoutit
For Web API, a good tutorial found at Web API in ASP.Net MVC
Hope this helps!

What are the pros and cons of having a WebAPI in the same or different project [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I have an MVC application and the solution consist of three project as described below:
Store.Domain : Holds the domain entities and logic (repositories created with the Entity Framework).
Store.WebUI : Holds the controllers and views; acts as the UI for the application.
Store.UnitTests : Holds the unit tests for the other two projects.
I will use WebAPI 2 in my application in order to create web services for some of the Android applications. Now I am not sure about the issues below:
1) By keeping in mind security and maintenance concerns, should I create a separate project for WebAPI or use WebAPI in the Store.WebUI project? As I will also install WebAPI documentation nuget and it will create several folders and files in the project, I think creating a new project maybe better.
2) Assuming to create a new project dedicating for WebAPI, what would be the project type and choices for the WebAPI project? Is it true the following selections as indicated on the screenshot?
Project Type: ASP.NET Web Application
Project Template: Just select Web API
Thanks in advance.
WebApi is an alternative Service oriented application from Microsoft just like WCF. But WCF uses SOAP protocol and WebAPI uses HTTP protocol for communication.
So if you are using WEBAPI to provide service for your MVC application you would host that WEB API service seperately and consume its service by MVC application,
If you want them (MVC and WebAPI) to use in the same project, follow this rules from this article.
Hope that helps.

How should I structure an MVC 4 + WebApi + Linq-to-Sql solution? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I understand that stackoverflow uses Linq to SQL. I decided that since stackoverflow uses linq to sql (and in my opinion works well in a high traffic site), that I would continue using it in my MVC 4 application.
What I have thus far in my solution is an MVC 4 internet project, an web api project, model class library, used to override some of the mapping in linq to sql, and then my linq to sql library project.
I noticed when I added a web api project to the solution, the api project also had views, controllers etc. as the regular mvc 4 project.
Does the web api project provide the same abilities for views etc, as MVC 4 web project?
What would you recommend for project settings...
Eliminate the mvc 4 internet project and just use the web api.
Eliminate the web api and use a repository?
Use both the mvc 4 internet project and the web api?
Or ????? and why?
I am moving an asp.net web forms application over to mvc. Since stackoverflow uses linq to sql I decided re-use my linq to sql library instead of creating linq to entities.
All data access and manipulation is done using linq to sql, so it's a lot easier for me to just move the queries over to the web api.
I want to re-use as much code as possible and will be using Telerik's Kendo UI for MVC.
The application will need to work both on-line and offline, so I thought the api would be good.
But after noticing that the api contains the same object types as the mvc internet project, I didn't see why I would use both the internet and api mvc projects.
Thanks
You can go both ways. If you create a Web API project, it comes with all MVC4 features. In the controllers folder project, if you right click and say new, you have the option to create a Web API controller or an MVC controller. Since both have different URLs(Web APi will have /api/ in the url by default), you can decide whether to call MVC4 controller or Web API controller.

Asp.net Mvc advantages over asp.net? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Biggest advantage to using ASP.Net MVC vs web forms
In Model View Controler, I read in one of the articles about asp.net mvc, that testing is easy in MVC -- how? Can anybody explain to me, or any reference?
The key testability advantage ASP.Net MVC has over ASP.Net Webforms is a feature of the MVC pattern itself: separation of concerns. The platform pushes the business logic (models), program logic (controllers), and UI (views) towards separation, so that they can be tested (unit tested, that is) separately.
There are also indications that Microsoft's version of MVC is designed with testability in mind. For example, MVC classes like the Controller and HttpContext implement an interface, which makes it easier to mock them in unit tests.
Of course, using ASP.Net MVC doesn't guarantee a testable application (although it does make it easier). Likewise, using Webforms doesn't prohibit one (although it's easier to end up with untestable spaghetti code without separation of concerns enforced). As always, using a test-driven approach is more important than which platform you're using.
There are lots of Q&A is available already on this portal regarding to your questions.
Some of them are:
ASP.Net MVC vs ASP.Net Forms
Biggest advantage to using ASP.Net MVC vs web forms
https://stackoverflow.com/questions/6901554/asp-net-vs-asp-net-mvc
ASP.Net VS ASP.Net MVC
You can fin more. For next time before posting any question just check it once whether it's already discussed or not.

Resources