Click here to Skip to main content
15,921,793 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello ! So the title pretty much says it all. I am creating ASP.NET(MVC) apps, and i am wondering where should i use web api + jQuery and where should use razor syntax. I personally think that when there is not a chance of creating an client(desktop, xamarin app) and the app is not big(so you don't necessary want to "save resources" from the server) there is not a reason of creating a web api .. and you should use razor syntax .... but is that true ? I am asking this because i 've heard some guys saying that using razor is bad coding practice. Is that true ?

What I have tried:

Nothing to write here. Is a programming question.
Posted
Updated 20-Aug-17 10:57am

1 solution

You comparing apples to oranges.

Razor is a hybrid syntax of HTML and either C# or VB.NET used to generate HTML pages for a browser client.

A Web API returns no HTML but data formatted in either JSON or XML.

So, what are you doing with this site? What is the target client?

You could even do both, with the WebAPI servicing both remote clients AND your website, where the code-behind makes calls to the Web API you build.
 
Share this answer
 
Comments
xXxRevolutionxXx 21-Aug-17 16:19pm    
Very nice answer. I haven't thought possible to use the web api from the backend.I accept your solution !

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900