M
M
mletov2018-02-13 13:00:23
ASP.NET
mletov, 2018-02-13 13:00:23

Can a WebApi project really do without Razor?

Read the comments here on the toaster. In one of them, the author wrote that his REST-based project on WebApi generally works without Razor. I wanted to clarify the details from him, but, unfortunately, I lost the topic, so I'm asking here.
Is there really such a practice to do without Razor in a component approach instead of a monolithic one?
Is it really cost-effective to pull everything out with Ajax through the API? And how is the muzzle of the project done then? Files like index.html are typeset, css and javascript are connected to it? And if, for example, you need a title or description on pages for search engines, should they be immediately in the body of the page, and not be obtained via ajax?
And most importantly, if this is practiced, then maybe there is an example on github?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Eremin, 2018-02-13
@mletov

So. Well, let's start with MVC, the idea of ​​which is to delimit the three functions of a web application and make them interchangeable. This means that if, for example, your database was on MSSQL, but became MySQL or moved somewhere else, then you will not need to make changes to V and C (provided that the view and controller really do not depend on the model
) V can be either replaceable or not at all
Razor is, of course, interesting, but, frankly, it is quite difficult to meet it in industrial development
. But there are a lot of projects on ASP.NET + Angular / Vue / Backbone
All of them work on the idea that the server returns the data in its pure form (JSON or XML), and some kind of web is responsible for the presentation
We can safely say that most modern web projects choose the API + Web approach. Another plus is that, because the server gives only data (without markup), it is very easy to add a mobile application to the project - it accepts the same data, but works with them in its own way. Or maybe your API will be used by another system? So again - the data is in clean form and it will not be necessary to parse html
Therefore:
Yes. And she's more preferable
Worth it, because receiving data in a "pure" form, frontend developers feel freer to work with the face. And plus, the ability to connect a mobile phone
Everything you like about the frontend (Frameworks, libs, templating engines or just pure html, css, js)
Well, Angular, for example, is somehow indexed by Google (well, if only it wasn’t indexed). Articles worth reading on this topic.
Yes. Search for repositories/books/videos using the words ASP.NET + Angular - you won't be looking for long

T
tison, 2018-02-13
@tison

In cases where the backend is a web api, the muzzle can be an application on Angular, React, Vue ... As for whether search engines can index the pages of such sites or not, I can’t say for sure, but Google seems to be able to. If SEO is important, then you can render views on the server. All the frameworks I have listed can do this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question