Inline tag not executing in an asp.net master page

This really should be so very simple…

I have an asp.net master page which is working as expected. It includes some asp: tags without any problems.

The master page also includes the line

<link rel="stylesheet" type="text/css" href="css/main.css?v=<%=variableName%>" rel="nofollow noreferrer noopener" />

which is not executing. The output HTML has this as

<link rel="stylesheet" type="text/css" href="css/main.css?v=&lt;%=variableName%>" rel="nofollow noreferrer noopener" />

I do not work in asp.net very much so hopefully I have missed something super simple. Any suggesions on how to stop my inline asp tags from being HTML-encoded?

Many thanks.

EDIT

So it just gets sillier

This works: href="css/main.css?v=<%:" rel="nofollow noreferrer noopener"variableName"%>" and outputs href="css/main.css?v=variableName" rel="nofollow noreferrer noopener"

However this doesn’t: href="css/main.css?v=<%:variableName%>" rel="nofollow noreferrer noopener" and outputs href="css/main.css?v=&lt;%:variableName%>" rel="nofollow noreferrer noopener"

Seriously I never thought I would say it but PHP makes WAYYY more sense!

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Try this one

UPDATE: <link rel="stylesheet" type="text/css" href=<%="'css/main.css?v="+"34'"%> />


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x