MVC @import html keyword

2019-03-18 06:03发布

问题:

I'm trying to use:

<style>@import url("css/main.css");</style>

but mvc treats it as .net code in razor view. "CS0103: The name 'import' does not exist in the current context" how do i fix it? thanks

回答1:

Double the @ to fix the issue:

<style>@@import url("css/main.css");</style>

More details here.



回答2:

Use two @@ characters to escape them, that should fix it.