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

1928 у кіно

Захаров Федір Захарович

Ель Греко