Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, November 1, 2018 5:15 PM
Using Visual Studio 2015 I perform the following actions...
1) New Project: ASP.Net Empty Web Application, WebApplication1
2) Add new web form, WebForm1.aspx
3) Create new folder, App_Code
4) Add new class, Class1.cs to App_Code folder. Its namespace is created as WebApplication1.App_Code
5) Add "using WebApplication1.App_Code" to WebForm1.aspx.cs
A red line appears under the text, "App_Code" in the using statement showing the error in the subject of this post.
I then changed the namespace for Class1 to be the same as the web form, WebApplication1 and instantiated a Class1 variable inside WebForm1.Page_Load() and it gets a red line saying, Class1 doesn't exist in this context.
What am I missing? This is stuff I've been doing successfully for years...
How do I declare a class in my App_Code folder and then actually use it in a Web Form?
Thanks!
Curt
All replies (1)
Thursday, November 1, 2018 7:25 PM ✅Answered
Select Class1 in Solution Explorer, right-click, go to Properties (or press <F4>) and make sure that Build Action is “Compile”.