Asp.Net Core 2.1 Using ViewComponents between Head tags for Getting Metadata Dynamicly2019 Community Moderator ElectionMultiple ViewComponents ids in one View in Asp.Net CoreViewComponent With CRUD Operations in ASP.NET CORE MVCHow share ViewData between ViewComponent in Asp.net coreIdentity in ASP.Net Core 2.1 : Customize AccountControllerWanting to Create a Unit Test for ViewComponent in ASP.NET Core 2.1Asp.Net Core 2.1: Invoking ViewComponent in PageModel.Net Core 2.1 : Referencing viewcomponents inside DLLView vs PartialView vs ViewComponent vs TagHelpers (ASP.NET Core 2.1)ASP.NET Core MVC submit form in partial view / ViewComponentHow can I access the content within the tags in an ASP.NET CORE ViewComponent?

Using "wallow" verb with object

Why using two cd commands in bash script does not execute the second command

Have researchers managed to "reverse time"? If so, what does that mean for physics?

What options are left, if Britain cannot decide?

Can hydraulic brake levers get hot when brakes overheat?

Is having access to past exams cheating and, if yes, could it be proven just by a good grade?

How to answer questions about my characters?

Know when to turn notes upside-down(eighth notes, sixteen notes, etc.)

Brexit - No Deal Rejection

Humanity loses the vast majority of its technology, information, and population in the year 2122. How long does it take to rebuild itself?

How is the Swiss post e-voting system supposed to work, and how was it wrong?

Is it normal that my co-workers at a fitness company criticize my food choices?

Why is stat::st_size 0 for devices but at the same time lseek defines the device size correctly?

Rules about breaking the rules. How do I do it well?

What does it mean to make a bootable LiveUSB?

Can the damage from a Talisman of Pure Good (or Ultimate Evil) be non-lethal?

Instead of Universal Basic Income, why not Universal Basic NEEDS?

Employee lack of ownership

Sword in the Stone story where the sword was held in place by electromagnets

Did CPM support custom hardware using device drivers?

Is Mortgage interest accrued after a December payment tax deductible?

Life insurance that covers only simultaneous/dual deaths

Is a lawful good "antagonist" effective?

What is the greatest age difference between a married couple in Tanach?



Asp.Net Core 2.1 Using ViewComponents between Head tags for Getting Metadata Dynamicly



2019 Community Moderator ElectionMultiple ViewComponents ids in one View in Asp.Net CoreViewComponent With CRUD Operations in ASP.NET CORE MVCHow share ViewData between ViewComponent in Asp.net coreIdentity in ASP.Net Core 2.1 : Customize AccountControllerWanting to Create a Unit Test for ViewComponent in ASP.NET Core 2.1Asp.Net Core 2.1: Invoking ViewComponent in PageModel.Net Core 2.1 : Referencing viewcomponents inside DLLView vs PartialView vs ViewComponent vs TagHelpers (ASP.NET Core 2.1)ASP.NET Core MVC submit form in partial view / ViewComponentHow can I access the content within the tags in an ASP.NET CORE ViewComponent?










0















I want to add metadatas to layout page for SEO dynamicly from admin panel. Sample:



<meta content="" name="description" />
<meta content="XXX" name="author" />


In MVC5, I use:
<head>
@Html.Action("GetMetatags", "Home")
</head>



and easily get them.
But in Asp.Net Core 2.1, I try to use ViewComponents instead of partial view like this:



<head> 
@await Component.InvokeAsync("MetaDatasForSEO")
</head>


The problem: I can get metadatas correctly but not between <head> tags. Just in <Body> tag...So it doesnt works. Thanks for help...










share|improve this question






















  • Is there any demo to reproduce your issue, it works correctly when appending @await Component.InvokeAsync("MetaDatasForSEO") in _Layout.cshtml. Check the result

    – Tao Zhou
    Mar 7 at 7:07












  • Thanks Tao. I think there should be a latency because of async process and getting data from database and I think, the result metadatas dislay in body because of this latency. Try to get metadatas with js. But after your message, i have checked again the other codes carefully and noticed the viewcomponent cshtml: It seems: @Model.Metatags So, that string result display in body as string, not hidden metatags. Then changed it @Html.Raw(Model.Metatags). Now it works. thanks...

    – Aykarnz
    Mar 7 at 10:09











  • Glad it works now.

    – Tao Zhou
    Mar 7 at 11:58















0















I want to add metadatas to layout page for SEO dynamicly from admin panel. Sample:



<meta content="" name="description" />
<meta content="XXX" name="author" />


In MVC5, I use:
<head>
@Html.Action("GetMetatags", "Home")
</head>



and easily get them.
But in Asp.Net Core 2.1, I try to use ViewComponents instead of partial view like this:



<head> 
@await Component.InvokeAsync("MetaDatasForSEO")
</head>


The problem: I can get metadatas correctly but not between <head> tags. Just in <Body> tag...So it doesnt works. Thanks for help...










share|improve this question






















  • Is there any demo to reproduce your issue, it works correctly when appending @await Component.InvokeAsync("MetaDatasForSEO") in _Layout.cshtml. Check the result

    – Tao Zhou
    Mar 7 at 7:07












  • Thanks Tao. I think there should be a latency because of async process and getting data from database and I think, the result metadatas dislay in body because of this latency. Try to get metadatas with js. But after your message, i have checked again the other codes carefully and noticed the viewcomponent cshtml: It seems: @Model.Metatags So, that string result display in body as string, not hidden metatags. Then changed it @Html.Raw(Model.Metatags). Now it works. thanks...

    – Aykarnz
    Mar 7 at 10:09











  • Glad it works now.

    – Tao Zhou
    Mar 7 at 11:58













0












0








0








I want to add metadatas to layout page for SEO dynamicly from admin panel. Sample:



<meta content="" name="description" />
<meta content="XXX" name="author" />


In MVC5, I use:
<head>
@Html.Action("GetMetatags", "Home")
</head>



and easily get them.
But in Asp.Net Core 2.1, I try to use ViewComponents instead of partial view like this:



<head> 
@await Component.InvokeAsync("MetaDatasForSEO")
</head>


The problem: I can get metadatas correctly but not between <head> tags. Just in <Body> tag...So it doesnt works. Thanks for help...










share|improve this question














I want to add metadatas to layout page for SEO dynamicly from admin panel. Sample:



<meta content="" name="description" />
<meta content="XXX" name="author" />


In MVC5, I use:
<head>
@Html.Action("GetMetatags", "Home")
</head>



and easily get them.
But in Asp.Net Core 2.1, I try to use ViewComponents instead of partial view like this:



<head> 
@await Component.InvokeAsync("MetaDatasForSEO")
</head>


The problem: I can get metadatas correctly but not between <head> tags. Just in <Body> tag...So it doesnt works. Thanks for help...







asp.net-core meta-tags asp.net-core-2.1 asp.net-core-viewcomponent






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 6 at 18:39









AykarnzAykarnz

103




103












  • Is there any demo to reproduce your issue, it works correctly when appending @await Component.InvokeAsync("MetaDatasForSEO") in _Layout.cshtml. Check the result

    – Tao Zhou
    Mar 7 at 7:07












  • Thanks Tao. I think there should be a latency because of async process and getting data from database and I think, the result metadatas dislay in body because of this latency. Try to get metadatas with js. But after your message, i have checked again the other codes carefully and noticed the viewcomponent cshtml: It seems: @Model.Metatags So, that string result display in body as string, not hidden metatags. Then changed it @Html.Raw(Model.Metatags). Now it works. thanks...

    – Aykarnz
    Mar 7 at 10:09











  • Glad it works now.

    – Tao Zhou
    Mar 7 at 11:58

















  • Is there any demo to reproduce your issue, it works correctly when appending @await Component.InvokeAsync("MetaDatasForSEO") in _Layout.cshtml. Check the result

    – Tao Zhou
    Mar 7 at 7:07












  • Thanks Tao. I think there should be a latency because of async process and getting data from database and I think, the result metadatas dislay in body because of this latency. Try to get metadatas with js. But after your message, i have checked again the other codes carefully and noticed the viewcomponent cshtml: It seems: @Model.Metatags So, that string result display in body as string, not hidden metatags. Then changed it @Html.Raw(Model.Metatags). Now it works. thanks...

    – Aykarnz
    Mar 7 at 10:09











  • Glad it works now.

    – Tao Zhou
    Mar 7 at 11:58
















Is there any demo to reproduce your issue, it works correctly when appending @await Component.InvokeAsync("MetaDatasForSEO") in _Layout.cshtml. Check the result

– Tao Zhou
Mar 7 at 7:07






Is there any demo to reproduce your issue, it works correctly when appending @await Component.InvokeAsync("MetaDatasForSEO") in _Layout.cshtml. Check the result

– Tao Zhou
Mar 7 at 7:07














Thanks Tao. I think there should be a latency because of async process and getting data from database and I think, the result metadatas dislay in body because of this latency. Try to get metadatas with js. But after your message, i have checked again the other codes carefully and noticed the viewcomponent cshtml: It seems: @Model.Metatags So, that string result display in body as string, not hidden metatags. Then changed it @Html.Raw(Model.Metatags). Now it works. thanks...

– Aykarnz
Mar 7 at 10:09





Thanks Tao. I think there should be a latency because of async process and getting data from database and I think, the result metadatas dislay in body because of this latency. Try to get metadatas with js. But after your message, i have checked again the other codes carefully and noticed the viewcomponent cshtml: It seems: @Model.Metatags So, that string result display in body as string, not hidden metatags. Then changed it @Html.Raw(Model.Metatags). Now it works. thanks...

– Aykarnz
Mar 7 at 10:09













Glad it works now.

– Tao Zhou
Mar 7 at 11:58





Glad it works now.

– Tao Zhou
Mar 7 at 11:58












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55030071%2fasp-net-core-2-1-using-viewcomponents-between-head-tags-for-getting-metadata-dyn%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55030071%2fasp-net-core-2-1-using-viewcomponents-between-head-tags-for-getting-metadata-dyn%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved