tags:

views:

166

answers:

5

If you create an ASP.NET Web Site project and run it, you get a blank page. If you go into the default CodeBehind file, add into the Page_Load method throw new Exception();, save the file, and refresh it in the browser (without rebuilding), the server automatically rebuilds the project and the page will error.

I have a project that I am working on now where refreshing the page does not cause the project to be rebuilt (the new aspx files are used but the old DLLs are used with them). What causes this, and how do I correct it?

+1  A: 

Is this new project a web application project by any chance? I believe you have to actually build that before changes will be seen.

Paddy
I do not know what a "Web Application Project" is but the project was created as an "ASP.NET Web Site".
CGamesPlay
A: 

Web Application Project is a separate type of project that requires all code behind to be build. The resulting dll is build under the bin folder. The code behind files are not used in execution, and is the preffered way of doing it if you don't want to expose your code at the installed web server, and to be sure execution is faster (never compiling in runtime).

When you creatied it as "ASP.NET Web Site", it is NOT a "Web Application Project".

awe
A: 

You are using the Website model. The pages will be compiled when you access them. Class Library projects in the same solution will not. Hence why you see this behaviour.

By default, the ASPX, code behind and App_Code source files get compiled. If you have a seperate project in the solution (a BLL or DAL perhaps), these will not be updated by simply refreshing the browser.

So to correct it you could do a proper build in Visual Studio, or you could move the class files you want to change into App_Code. Personally I'd stick with the former (actually I don't ever use the Website option- always Web application project).

RichardOD
I don't understand. You said that code behind files get updated. This is the behavior I want, and the behavior that I am not getting.
CGamesPlay
A: 

Only code which is in App_Code will be automatically recompiled when it changes. If your code lives anywhere else, then it's part of the pre-built DLL you get when you hit "compile".

Brad Wilson
A: 

OK. Have you got 'Edit and Continue' enabled? MSDN

Paddy
Yes, toggling does not change the behavior I'm experiencing.
CGamesPlay