Can we use @using static in mvc views



Many developers wanted to use @using static reference in views. But as off now below aspnet.core it is not supported. We cannot use directly @using static in views. However there may be other ways to do so.

View code:

@using static testnamespace.CommonClass    --> this gives error 
@{ 
    Layout = null;
}

C# code:

namespace testnamespace
{   

    public static class CommonClass
    {
      //code 
    }
}

Here, Razor doesn't understand whether "using" valid or not. 

Labels: using static mvc views, using static in views mvc, static reference in mvc views, @using static in mvc view
Subscribe

Receive Quality Tutorials Straight in your Inbox by submitting your Email below:

Delivered by FeedBurner

Protected by Copyscape Duplicate Content Checker