-
Notifications
You must be signed in to change notification settings - Fork 519
Using @addTagHelper in ASP.NET Core WebAPI #1002
Comments
In WebApi you're not using Razor views, so it doesn't make sense to use tag helpers. Instead, look into using the |
I've developed an web application built using ASP.NET Core Web API and Angular 4. My module bundler is Web Pack 2. But I would like to use server side prerendering. I would like to add metatags into head:
Is it possible to do without "ViewData"?` |
You're going to have to create all the tags and add them to your rendered HTML. |
@MarkPieszak yeah, I've added these tags into head by metaService:
and rendered html at browser looks like this when I inspect this element in a browser:
However, view source in a browser does not have any rendered html. I've developed an web application built using ASP.NET Core Web API and Angular 4. My module bundler is Web Pack 2. But I would like to use server side prerendering to be crawled by SEO I can post my news from my web site by Google, Facebook, Twitter, other social nets. |
I am following this tutorial of "Microsoft.AspNetCore.SpaServices Server Side Prerendering" and there are two important steps to use power "Microsoft.AspNetCore.SpaServices":
1. Go to your "Views/_ViewImports.cshtml" file, and add the following line:
@addTagHelper "*,
Microsoft.AspNetCore.SpaServices"`2. Choose a place in one of your MVC views where you `want to prerender a SPA component. For example, open "Views/Home/Index.cshtml", and add markup like the following:
<div id="my-spa" asp-prerender-module="ClientApp/boot-server"></div>
But "Web Api" does not have "Views" folder. How can I do above steps in Web API?
The text was updated successfully, but these errors were encountered: