1

By default, ASP.NET splits up your web.config so that razor-related items are included in "~/views/web.config" while everything else is put into "~/web.config".

For me, it would make sense to combine all of it into one so that it would apply to the entire site. Would there be any downside to doing this?

dcastro
  • 66,540
  • 21
  • 145
  • 155
William
  • 3,335
  • 9
  • 42
  • 74
  • Not that I'm aware of. I'm pretty sure that is simply how Microsoft's MVC works. – user3358344 Mar 01 '14 at 01:04
  • http://stackoverflow.com/questions/6204341/what-does-the-web-config-file-do-in-the-views-folder-of-a-mvc-project – Shyju Mar 01 '14 at 01:05
  • @Shyju - Okay, I see where the Web.config in the views adds the BlockViewHandler. But is that the only required purpose of this folder? I ask because alot of code such as namespace imports are also there which seem to be able to be moved - unless there is something else I am missing? – William Mar 01 '14 at 01:26

1 Answers1

1

As you've seen it's valid to have multiple web.config files in a website, under different folders.

In your main web.config (at the site root), you can specify different configuration at different folders in the site using the <location> element. Having a web.config file in that folder (location) instead has the same effect, so consolidation is possible.

However, I would suggest leaving it be:

  • It's arguably easier to manage this separate configuration which is specific to the view engine being used.
  • Any future maintainers will be familiar to MVC and so expect to see the extra web.config there.
  • The same could be said for any Nuget packages which you may need, that expect it to be there also.

There's bound to be other reasons too, but they come to mind right now.

Matt Tester
  • 4,663
  • 4
  • 29
  • 32
  • After playing around with different configurations I tend to agree - it seems like while consolidation is technically possible, it is going against the grain. Two configs seems like the way to go - thanks! – William Mar 02 '14 at 17:33