Quantcast
Channel: Troubleshooting
Viewing all articles
Browse latest Browse all 1814

IIS Express - Web API application fails when multiple segments in application path

$
0
0

I have the following in applicationhost.config (note that the application path has multiple segments):

           <site name="test-Site" id="12">
                <application path="/" applicationPool="Clr4IntegratedAppPool">
                    <virtualDirectory path="/" physicalPath="C:\Users\some\bogus\path" />
                </application>
               <application path="/xxx/yyy" applicationPool="Clr4IntegratedAppPool">
                   <virtualDirectory path="/" physicalPath="C:\path1\path2\path3" allowSubDirConfig="false" />
               </application>
               <bindings>
                    <binding protocol="http" bindingInformation="*:41000:localhost" />
                </bindings>
            </site>

And the following route configured:

            config.Routes.MapHttpRoute("Route1", "route1/route2/{param1}/{param2}", new { controller = "MyController", action = "MyMethod" });

The following url: http://localhost:41000/xxx/yyy/route1/route2/1/2 , MyController/MyMethod is invoked, but fails when it tries to access a connection string from the web.config at c:\path1\path2\path3\web.config.  

Procmon shows that the web.config is being read to EOF (several times).  If the allowSubDirConfig parameter is removed from the <virtualDirectory>, then in addition to reading c:\path1\path2\path3\web.config it searches (unsuccessfully) for web.config files in c:\path1\path2\path3\route1, c:\path1\path2\path3\route1\route2, c:\path1\path2\path3\route1\route2\1, and c:\path1\path2\path3\route1\route2\1\2, and fails the same way (connection string not found).  Also setting a breakpoint in the controller,  ApplicationPath ("/xxx/yyy"), AppRelativeCurrentExecutionFilePath ("~/route1/route2/1/2") and MapPath("~/") ("c:\path1\path2\path3") in System.Web.HttpContext.Current.Request are what they should be.

Modifying the virtual directory so that the path has only one segment:

<application path="/xxx" applicationPool="Clr4IntegratedAppPool">

And modifying the url:

http://localhost:41000/xxx/route1/route2/1/2

in this case the connection string is correctly accessed from the web.config and the request is successful.

Is there any reason why an application path cannot contain more than one segment in IIS Express?

Thanks in advance!


Viewing all articles
Browse latest Browse all 1814

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>