I have created a Helper method in MVC3 Razor project as(Helpers.cshtml)
@helper Link(string fileName, UrlHelper url){
<link href="@url.Content("~/Content/" + fileName)"
rel="stylesheet" type="text/css" />
}
But i get a warning tooltip “Element link cannot be nested within element ‘link'”.
I found similar type of question on Asp.net
Error when using link href inside my ContentPlaceHolder
Do we have a solution for this.
Keep in mind that you should only have
<link>tags in the<head>and not the<body>. The tooling is unable to confirm from where you’ll call this helper, so it barks.You can verify that this is what’s going on by temporarily wrapping the helper in a valid skeleton of markup as below. The warning should go away. You can then confirm the negative case by changing
linkto some made-up tag likefoo, or by removing thetitle, and watch those errors then appear. You should then be comfortable that as long as you only call your helper from inside<head>sections, your resultinglinkmarkup is ok.