Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use the 'using' statement in my aspx views? (ASP.NET MVC)

People also ask

Can you use ASPX pages in MVC?

If you add a plain ASPX page to an ASP.NET MVC project, well, it just works like a charm without any changes to the configuration. If you invoke the ASPX page, the ASPX page is processed with viewstate and postbacks.

Can you use C# code in your views?

Generally, you can put your c# code wherever you want. The only conventions that MVC adheres to by default are the Controllers and Views folder.

Can we use view state in MVC?

ASP.NET MVC does not use ViewState in the traditional sense (that of storing the values of controls in the web page). Rather, the values of the controls are posted to a controller method.


Do you mean like

<%@ Import namespace="MyProgram.MyNamespace" %>

Also, inside the root <configuration> tag of web.config, you can add:

<system.web>    
    <pages>
       <namespaces>
          <add namespace="System" />
          <add namespace="System.Collections" />
          <add namespace="System.Collections.Specialized" />
          <add namespace="System.Configuration" />
          <add namespace="System.Text" />
          <!-- etc -->
       </namespaces>
    </pages>
</system.web>