我应该使用带有jquery或razor语法的web api [英] Should I use web api with jquery or razor syntax
本文介绍了我应该使用带有jquery或razor语法的web api的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的尝试:
没什么写在这里。是一个编程问题。
解决方案
你将苹果与橙子进行比较。
Razor是一种混合语法HTML和C#或VB.NET用于为浏览器客户端生成HTML页面。
Web API不返回HTML,而是以JSON或XML格式化数据。 br />
那么,你在这个网站做什么?什么是目标客户端?
您甚至可以同时执行这两项操作,WebAPI为远程客户端和您的网站提供服务,其中代码隐藏调用Web API你建立。
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.
解决方案
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.
这篇关于我应该使用带有jquery或razor语法的web api的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文