Auto-generated "App_Web********.cs" files in temp directory causing build errors

This is not related to IIS, local or otherwise. That long, strange file name you are seeing is the name the compiler gives to a view when it compiles it. What everything you have described is telling you is that you have a compilation error in one of your views. It could be mismatched HTML tags, a bad model property call, etc.

Looking at your error message, you have a view in the /Views/Home/MostRecentMember.cshtml. Further, it appears that you are indeed either missing the namespace for your model declaration or declared the wrong namespace for the model that you are trying to send in.

Deleting the strangely named file will do nothing as when you rebuild, it will come back, most likely with a different name.


I faced the same error after I changed the namespace of web application, I also renamed my solution and web project also. After lots of tricks and tips finally this solution worked for me.

  1. I inspected the app App_start files to find any reference to old namespace and found nothing
  2. I then searched web.config and Global.asax but no success.
  3. Finally I searched in web.config listed under Views folder in solution and there I found reference of old name space under. Changed this to NewNamespace and ran the application. This time it worked.


I had this again today, there must be a bug in visual studio that causes it to try and compile all cshtml files in the views folder. Even if they are not part of the project. Your best bet is to click show all files in the solution explorer, find the rogue file and delete it.