I have a C # ASP.Net Razor page (not MVC) ...
@using QuickCodeLearning.Customers.Utilities; @{ var cus = CustomerUtilities.GetCustomerInformation(1); } <html> <head> <title> Display a Customer </title> </head> <body> <p>@cus.fname @cus.lname @cus.FavFruit</p> </body> </html>
I enable the class library (QuickCodeLearning.Customers.Utilities) using the using statement.
Everything is working fine.

My question is: can I add this class library to my Web.Config file so that I don't have a using statement at the top of each page?
Here is my Web.Config file ...
<?xml version="1.0"?> <configuration> <connectionStrings> <add name="CustomersEntities" connectionString="metadata=res://*/CustomersEF.csdl|res://*/CustomersEF.ssdl|res://*/CustomersEF.msl;provider=System.Data.SqlClient;provider connection string="data source=LT5V6V8W1\SQLSERVERROCKS;initial catalog=sandbox;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" /> </connectionStrings> <system.web> <authentication mode ="Windows"/> <identity impersonate="true"/> <compilation debug="true" targetFramework="4.0"/> </system.web> </configuration>
I tried adding <page> <& namespace GT; to a Web.Config file like this ...
<?xml version="1.0"?> <configuration> <pages> <namespaces> <add namespace="QuickCodeLearning.Customers.Utilities" /> </namespaces> </pages> <connectionStrings> <add name="CustomersEntities" connectionString="metadata=res://*/CustomersEF.csdl|res://*/CustomersEF.ssdl|res://*/CustomersEF.msl;provider=System.Data.SqlClient;provider connection string="data source=LT5V6V8W1\SQLSERVERROCKS;initial catalog=sandbox;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" /> </connectionStrings> <system.web> <authentication mode ="Windows"/> <identity impersonate="true"/> <compilation debug="true" targetFramework="4.0"/> </system.web> </configuration>
But that does not work. When I delete the using statement, the page stops working.
What am I missing?
Update:
The answer (which I'm sure is correct) does not work for me. My project does not have a Views folder. When I add a new folder to my web project and turn on the App.Config settings, it does not solve my problem. I closed and updated Visual Studio. I restarted IIS.
I noticed that the views folder is created when Visual Studio 2012 creates an MVC project, however I am not working with the MVC site here. I have a basic website that uses the Razor engine.
source share