Search code examples
c#cssasp.netstylesheetcdn

Cannot use "@" character in C# cdn link to stylesheet


I'm trying to use this link inside a line of code in my cshtml file in order to access the mdi stylesheet: "https://cdn.jsdelivr.net/npm/@mdi/font@4.x/css/materialdesignicons.min.css".

For some reason, my program is taking issue with the '@' character before the mdi; it is hilighting it in yellow. When I try to run the code, I get this message:

error CS0103: The name 'mdi' does not exist in the current context

Interestingly, the other '@' in the string does not cause any issues. Any idea? Thank you!


Solution

  • @ has special meaning in cshtml pages. You need to escape it using either @ or %40

    https://cdn.jsdelivr.net/npm/@mdi/font@4.x/css/materialdesignicons.min.css

    https://cdn.jsdelivr.net/npm/%40mdi/font%404.x/css/materialdesignicons.min.css