{"action":"opened","issue":{"url":"https://api.github.com/repos/AmbitEnergyLabs/Nano/issues/31","labels_url":"https://api.github.com/repos/AmbitEnergyLabs/Nano/issues/31/labels{/name}","comments_url":"https://api.github.com/repos/AmbitEnergyLabs/Nano/issues/31/comments","events_url":"https://api.github.com/repos/AmbitEnergyLabs/Nano/issues/31/events","html_url":"https://github.com/AmbitEnergyLabs/Nano/issues/31","id":90566062,"number":31,"title":"Implement Ability to Specify Virtual Application Path for Self-Hosted Apps using HttpListenerNanoServer","user":{"login":"randyburden","id":458529,"avatar_url":"https://avatars.githubusercontent.com/u/458529?v=3","gravatar_id":"","url":"https://api.github.com/users/randyburden","html_url":"https://github.com/randyburden","followers_url":"https://api.github.com/users/randyburden/followers","following_url":"https://api.github.com/users/randyburden/following{/other_user}","gists_url":"https://api.github.com/users/randyburden/gists{/gist_id}","starred_url":"https://api.github.com/users/randyburden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/randyburden/subscriptions","organizations_url":"https://api.github.com/users/randyburden/orgs","repos_url":"https://api.github.com/users/randyburden/repos","events_url":"https://api.github.com/users/randyburden/events{/privacy}","received_events_url":"https://api.github.com/users/randyburden/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/AmbitEnergyLabs/Nano/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-06-24T05:03:09Z","updated_at":"2015-06-24T05:03:09Z","closed_at":null,"body":"Currently if a Nano application is using the HttpListenerNanoServer to self-host but the application is being hosted under a virtual directory, then when the RequestRouter uses the ```nanoContext.Request.Url.Path``` to iterate through the list of RequestHandlers, it doesn't find a match because the Path currently contains not only the user-defined path but is prefixed with the virtual directory.\r\n\r\nFor example if you are hosting a JSON API at \"/api/Customer\" but the website is using a load balancer and virtual application paths in order to re-use a subdomain such as \"https://operations.yourcompany.com/ApplicationName/api/Customer/GetCustomer\", then the ```Url.Path``` is going to be \"/ApplicationName/api/Customer/GetCustomer\" which means Nano is NOT going to route the request to the \"/api/Customer\" route because the route doesn't start with \"/ApplicationName\".\r\n\r\nThis problem doesn't exist in the SystemWebNanoServer because it uses the ```httpContext.Request.ApplicationPath``` in order to get the virtual application path which typically exists when the application is hosted under IIS. Nano is thus currently aware of virtual application paths and uses the ```Url.BasePath``` field to hold this value separate from the ```Url.Path``` in order to satisfy routing concerns.\r\n\r\nIn order to resolve this we need to introduce a property similar to ApplicationPath for the HttpListenerNanoServer so that developers can specify the virtual path during configuration of the NanoConfiguration object.\r\n\r\nCurrently developers can work around this by prefixing the virtual application path to every place a URL path is specified but this is not ideal and causes issues with the auto-added Nano MetadataRequestHandler which maps to \"/metadata/GetNanoMetadata\"."}}