C# – ASP.NET beginner woes with new Web Site

asp.netcvisual-studio-2008web-site-project

I'm a decently experienced .net developer for the desktop but this is my first stab at using ASP.NET and i'm stumped almost right away.

I've used the VS2008 "New Website" wizard and got a simple page working, codebehind page and all. But my next step of adding a simple static class for some utility methods to be used by all pages is not working out at all.

I've tried putting code in App_Code, I've tried creating a new library project and referencing it… everything always compiles fine in Visual Studio, but when uploaded to the server it simply refuses to find the namespace/class or recognize the library assembly. I've tried messing around with the web.config but haven't been able to find any way to reference the library assembly ("*" doesn't seem to do it for example).

The server pages says: Version Information: Microsoft .NET Framework Version:2.0.50727.3074; ASP.NET Version:2.0.50727.3074

Is there a best practice way for utility methods and how can I get my codebehind pages to recognize any class (or better yet namespace, or even assembly) besides itself?

The exact error i'm getting is:
CS0246: The type or namespace name 'MyCommon' could not be found (are you missing a using directive or an assembly reference?)

Best Answer

I'm assuming you do have a using statement that points to the namespace?

Something I see from time to time... on the server, have you (in IIS) marked the new folder as an "application"? It should have a cog in IIS. If you haven't, then it'll be looking in the wrong location for App_Code (the "application" tells it where the local app root is). Right-click, properties, "create application" (or something like that - I don't have a server to hand...)