This is post about specifying path attribute of location section in Web.config file. If you are not familiar with this section, go here
Examples in above article concern about ASP.NET where specifying path like ‘Page1.aspx’ is enough.
When I started mapping this knowledge to ASP.NET MVC, first time I failed.
As a test environment I used default ASP.NET MVC project (not empty) to have ready to work profject structure. What I wanted is to override key “test1” for my Index view. Index view was rendered through the Index action of Home controller. I started with following:
<location allowOverride="false" path="Index"> <appSettings> <add key="test1" value="test4" /> </appSettings> </location>
Unfortunately it did not work.
I found out that in MVCC, where routing module does all work, we need to specify full path to the action, not just the ‘action’ name. Like following (working code):
<location allowOverride="false" path="Home/Index">
Note here: specifying the path started from ~/ (root in MVC) is not allowed here and will not be resolved to the proper path!