We have rather intranet WebForms app that is using WebForms and is WebSite application. I am converting it to the Web Application Project using a great walkthrough from Microsoft.
WebSite vs Web Application
What are the major differences between these two projects and what advantages do I expect? You can find talkative comparison on MSDN or use more succinct one on StackOverflow. Basically the WebSite is a bunch of aspx files compiled on the fly on the server, while Web Application is precompiled dlls.
- Faster build. I am not sure why, but when I build website to check for static errors, I have to rebuild everything, rebuild takes few minutes, while WPA converted one is in seconds.
- Easier dependencies. WebSite requires user to manually specify dlls it depends on. Wweb Application is a real project and NuGet is available.
There are few other, but WPA is simply better while WebSite looks like technically inferior solution from 2005.
How does it work?
Great! Simply follow the walkthrough and you will be OK. I had it converted in several hours:
- Create Empty Web Project Application
- Copy all files (except the bin with *.refresh files and the publish file) from WebSite to the WPA
- Include all copied files to the WPA
- Right click on the project in Solution explorer, select Convert to Web Application, OK.
- The automatic conversion moved the App_Code to Old_App_Code, because it is the only place where WPA dynamically compiles code, and should be empty. Rename it to something sutable, e.g. App_Start
- Try to build the WPA, you will get a lot of errors because of dependencies. Add dependencies, preferably using NuGet.
- In 2 cases, I couldn’t access the aspx controls from code behind and had to resort to …FormView.FindControl(“ControlId”).Method() instead of ControlId.Method().
- You are done!