I've traditionally always put @using
directives in my ASP.NET Razor pages at the top, along with the @model
directive. However, for my overall layout, I want to make sure the DOCTYPE
declaration is at the very beginning of the document, so I want to push the @using
down a bit. Would you following be valid?
<!DOCTYPE html>
<html>
@using My.Library;
<head>
<title>Test web page</title>
...
Also, is there any documentation on where the @using
directive can be used in Razor pages? I can't seem to find any. Is it valid to use it after some other Razor code, for example, or does it have to appear first?
It is valid and you can use @using
any where before that you need that library.
MSDN:
HTML markup lines can be included at any part of the code.
so you can put DOCTYPE
at the top of page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With