In my .NET 6.0 / C# project, I have variable defined as
{
"Address": {
"AddressLine1": "220 E. Yut Drive Suite 20",
"AddressLine2": "giuuiu, CA 85679"
},
"AddressLine3": "22qwewqe"
}
I need to access addressLines
in 1 of the html files defined in project. I have tried below ways but none worked.
<p class=MsoNormal>
<span style='mso-bookmark:_Hlk45183937'>
<i><%$ AppSettings: Address.AddressLine1 %><o:p></o:p></i>
</span>
<span style='mso-bookmark:_Hlk45183937'>
<i><%$ appsettings: AddressLine3 %><o:p></o:p></i>
</span>
<span style='mso-bookmark:_Hlk45183937'>
<i><%=ConfigurationManager.AppSettings["AddressLine3"]%><o:p></o:p></i>
</span>
<%=ConfigurationManager.AppSettings("AddressLine3")%>
</p>
I need to know how can I access these params inside html file
2
Answers
If you you mean
.cshtml
, you could inject IConfiguration directlyBy the way
<%$ %>
is syntax for webform which is not used asp.net core 6.0.Trick it with a Route to a Controllers Get method that returns your HTML with the settings embedded.