app-code

Using the same App_Code classes across websites

Let's say you have a solution with two website projects, Website A and Website B. Now inside Website A's App_Code folder, there is a Class X defined in a ClassX.cs file. What do you do if Website B also needs access to ClassX.cs? Is there any way to share this file across App_Code folders? Assume that moving the file to a common li...

App_Code folder issues

So I'm having a really weird issue with my App_Code folder on a new website I'm designing. I have a basic class inside of a namespace in the App_Code folder. Everything works fine in the IDE when I setup the namespace and make an object from the class. It brings up the class summary on hover, and when you click on "go to deffinition...

How come classes in subfolders in my App_Code folder are not being found correctly?

I am getting the following error when I put class files in subfolders of my App_Code folder: errorCS0246: The type or namespace name 'MyClassName' could not be found (are you missing a using directive or an assembly reference?) This class is not in a namespace at all. Any ideas? ...

F# Code in an App_Code subfolder

I have a project with 2 subfolders in the App_code folder, one for VB and one for F# (C# files are in the root). I can access the VB classes just fine (via the namespace) but not the F# code. Has anyone had a problem like this and if so how did you fix it? Addendum: F# code that is not in the App_Code folder runs just fine. Is is as if ...

Creating Web Services in VS 2005

Why is that Web Service files (.asmx) have their code-behind placed in app_code folder by default unlike the regular .aspx files? ...

NET: Best Practices/guidelines for dividing namespaces between files?

What should be the general guidelines/gotchas for dividing application code (App_Code) into separate files? I've found that over time, the original files do not match up well with how the namespace hierarchy evolves. How do I keep application code containers organized intuitively over time? What PURPOSE should the file divisions aim t...

Cannot add App_Code folder to WebSite project

Using VS2008, I am trying to add an App_Code folder from add-->folder-->Add ASP_NET folder. The App_Code folder option is there as expected BUT ... it's disabled!? I am pretty sure I am working with a WebSite project (and not a Web Application) because I can add all the other ASP_NET folders (App_Data - App_themes etc) and also because...

Get MasterPage Hiddenfield Value From a User Class

Is there a way to get a value I am storing in a Master Page hidden field from a User Class which I created and placed in the App_Code folder of my ASP.Net 2.0 Application? Some examples would preferably in VB.Net is highly appreciated. Thanks. To give further details, assume the following: MasterPage.Master MasterPage.Master.vb MyPa...

asp.net web sites and default namespaces and LINQ Datacontext part 2

Let me try to ask this question from a different angle. I noticed that everytime an aspx page gets rendered in the browser using the "web site" model, a random assembly gets created 'on-the-fly' in the Temporary ASP.NET files. Analyzing the assembly in Reflector shows that the class created for any given .aspx file is under the "ASP"...

App_Code and web.config

Let's say I have a class (MyClass.cs) in App_Code (using a ASP.NET web site, not project). There's no namespace assigned to the class. How can I get that class to be valid in the web site .aspx pages? WHAT do I need to put in the web.config file and WHERE do I need to put it? Do I <add assembly tag or do I <add type ?? Since the ass...

ASP.NET - How do you reference a class that is not in app_code

I have created a MasterPage called MyMasterPage. public partial class MyMasterPage : System.Web.UI.MasterPage { protected void Page_Load(object sender, EventArgs e) { } } I have also created a class called Class1 in app_code: public class Class1 { public Class1() { MyMasterPage m; } } In Class1 I woul...

Why do custom membership provider files have to be in the app_code folder of my web app?

I'm writing a custom memberhsip provider based on the source for the SQL provider and I tried first making the SQL Provider a separate project. Yet, the web app wouldn't recognize it unless I put all the source in an APP_Code folder in my web app. Is this how you implement a custom provider? I thought I could simply reference the provid...

Where should I place additional classes in my MVC application

I have an ASP.NET MVC application which is using Linq to SQL classes placed in the Model folder. I want to create some extra classes that I would normally place in my BLL but I'm not sure how to work this with MVC. With WebForms I would have my DAL as a Class Library. My BLL as a class library that referenced my BLL. My Web Site that ...

Does App_Code in ASP.Net compile new code to a secondary temp AppDomain?

I am trying to better understand how the App-Code folder operates, and in particular I am curious how new objects that a new class in the App-Code folder are included in the current AppDomain. Is a second, temporary AppDomain created in the same manner as when I compile new objects with the CodeDom? In many ways the capability of movin...

Linq-to-SQL datacontext not generating an object

I am working in a .NET 2.0, recently upgraded to .NET 3.5 environment (VS2008, VB.NET) on an existing ASP.NET website project. I am able to generate a Linq-to-SQL Class (also called a DataContext?) in the App Code folder, drag over tables from an active connection, and save it. Let's call it MyDB. When I go to the code-behind file for my...

Can you move (or duplicate) the "special" .Net folders (App_*) in a subdirectory?

It is possible to have extra .Net "special" folders (App_Code, App_Themes, etc.) inside of a subdirectory, rather than in the root? I am integrating with a CMS that dumps an enormous amount of stuff in the root. I would like to keep all my stuff in a single subfolder, as this will greatly ease my SVN and deployment burden. As it sits,...

Accessing asp.net Profiles from App_Code

I am creating a base class from which specific pages are going to be derived. That is, instead of inheriting my pages from System.Web.UI.Page, they're inheriting from MyPage (which in turn, inherits from System.Web.UI.Page). However, I can't seem to be able to access the Profile property. Even though they both inherit from Page, I can o...

Page class outside of App_Code will not compile

I have a website that has 2 files as follows: page.aspx page.aspx.cs It used to be that I could just drop new files onto the web server and IIS would automatically compile the files and I could access the page e.g. http://www.website.com/page.aspx ... and the associated functionality in the page class contained in the .cs file woul...

ASP.NET : App_Code Class files not getting updated after modification

I have an ASP.NET web site where i am having App_code folder in which i put my class files (Business objects). Its running fine.But when i made some changes in the class (Added few proprties /Methods) and uploaded to the webserver (in production) its not getting affected in the live site.But this works pretty good when runs in local(so t...

Global Resources from class in App_Code

I've moved one of my classes to the App_Code folder (and namespace) and inside of this class I have a reference to a global resource: using Res = myProjectName.App_GlobalResources.Validation; Before I moved this class to the App_Code folder, everything worked alright. Now I get a runtime error stating that: CS0122: 'myProjectName.App...