How to correct it?
-
2In general, I prefer NOT to copy the Web.config file when I publish a web project, since usually I want a totally different web.config on my local machine from what I have on my server. – Brian Aug 20 '09 at 14:38
-
Any chance you could improve the contents of this question. ( If this was asked like this now, it would have been closed ) – Brad Gilbert Jun 05 '12 at 22:11
3 Answers
"Only files needed to run this application" means any build output files like DLLs and references in the bin folder and any files that have a Build Action of Content.
Since the web.config is neither of these, you'll have to change the publish option to All Project Files, or else copy the web.config manually.

- 68,708
- 30
- 194
- 223
-
Just small addition to the answer: Special care is required when renaming `web.config` because `BuildAction` is transferred! I found myself into this trouble when I renamed existing `web.config` to `web.prod.config` and copied in an external `web.config` outside VS ... `BuildAction` of new `web.config` was `None` and `web.prod.config` was `Content` – Learner Sep 10 '19 at 14:21
When you say 'ASP.NET web project', do you mean 'ASP.NET web application project'?
If so, the web.config should have a build action of Content by default. As Brandon mentioned, Content is then copied over to the publish destination.
To verify, select the web.config file in your Solution Explorer then use the Properties Window. An example:
example http://photos.tiredstudent.com/WebStorageHandler.ashx?tb=false&id=558

- 2,897
- 4
- 29
- 28
I know it sounds silly but make sure it is marked as 'Content' as it's Build Action under it's properties.

- 35,233
- 12
- 66
- 78