ASP.NET MVC inline tags do not work with <link href>

Every time I put the inline tag in the link href attribute, it is somehow automatically encoded. Is this the default behavior of ASP.NET? How can I dynamically set the HREF attribute using code? This is in MVC.

Trying something like this

<link href="<%: Link.Content.Jquery_css %>" rel="stylesheet" type="text/css" />

who did it (nothing has changed)

<link href="<%: Link.Content.Jquery_css %>" rel="stylesheet" type="text/css" />

and this one

<link href="<%= Link.Content.Jquery_css %> rel="stylesheet" type="text/css" />

which produced this (I couldn't remember the exact numbers, but it seems that the parentheses-percent-equal were encoded to refer to the format)

<link href="/View/Shared%25Link.Content.Jquery_css%25" %>" rel="stylesheet" type="text/css" />

Link.Content.Jquery_css - A strongly typed string containing a link created using T4MVC.

Add-on Information: I used ASP.NET MVC 2 in .NET 4 and testing in Firefox.

+3
source share
5 answers

- (<%: %>). , URL- , :

<link href="<%= Link.Content.Jquery_css %>" rel="stylesheet" type="text/css" />
+4

. ( .) , "runat = server" .

+5

":" "="

+3

Link.Content.Jquery_css. ASP.NET .

, .

+1

:

<head>
    <style type="text/css">
        @import "<%= ResolveUrl("~/content/styles.css") %>";
        @import "<%= ResolveUrl("~/content/print.css") %>" print;
    </style>
</head>
+1

Source: https://habr.com/ru/post/1776480/


All Articles