Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I import a namespace in Razor View Page?

How to import a namespace in Razor View Page?

like image 744
Amitabh Avatar asked Jul 13 '10 16:07

Amitabh


People also ask

Which namespace is used for razor view?

The namespace for Razor Engine is System. The Razor file extension is "cshtml" for the C# language. By default, Razor View Engine encodes html tags or scripts before it's being rendered to view that avoids Cross-Site Scripting attacks.

How do I declare a variable in Razor page?

To declare a variable in the View using Razor syntax, we need to first create a code block by using @{ and } and then we can use the same syntax we use in the C#. In the above code, notice that we have created the Code block and then start writing C# syntax to declare and assign the variables.


1 Answers

Finally found the answer.

@using MyNamespace 

For VB.Net:

@Imports Mynamespace 

Take a look at @ravy amiry's answer if you want to include a namespace across the app.

like image 156
Amitabh Avatar answered Sep 20 '22 15:09

Amitabh