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.
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.
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>
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