Tuesday, April 5, 2011

ASP.NET Web Application - compiling .cs files

I guess I have been using the Web Site model ever since .NET 2.0 and never looked back. Now I'm using the Web Application mode on a few projects. How do you tell the compiler to compile .cs files in the project? I assume you can do this since the newer-MVC projects do it for the Controllers.

I have a class, RestRouteHandler, that implements the IRouteHandler interface but because I think the .cs file is not being compiled I can't use it in my Global.asax.

From stackoverflow
  • use the "Build" menu in Visual Studio

    tyndall : I do. Then I get this message: The type or namespace name 'RestRouteHandler' could not be found (are you missing a using directive or an assembly reference?)
    tyndall : The other weird thing... Is when I add a .cs file to my project. It comes in completely blank. No code. weird.
    Jason : are you missing a reference or using statement in your code? If your templates are empty it may be worth it to try reinstalling VS.NET and all of the Service Packs.
  • Right-click the .cs file in the Solution Explorer and click Properties. Set the "Build Action" to compile.

    tyndall : That's the ticket. Ran into this other day and couldn't remember that's how I fixed it. Thanks. +1 and answer.
    Jon Tackabury : No problem. I ran into this a few times as well after I converted some projects to Web Applications.

0 comments:

Post a Comment