|Loading static content( index.html) from root||Sergey Shteyn||3/22/12 5:01 PM|
I would like to load my index.html from my root url ( http://localhost/index.html or http://localhost ) from a directory that is a subfolder of the root directory. In the past, I have using the ConfigureContention method to setup static from my DefaultNancyBootstrapper. See below:
protected override void ConfigureConventions(NancyConventions nancyConventions)
Is there anyway to change the method above for the requested client to point to the root of the url (http://localhost) and the content path to point to /rootDirectory/Dashboard ? I have tried to set requested client path to "" but that didn't work?
|Re: Loading static content( index.html) from root||Andreas Håkansson||3/22/12 11:33 PM|
Why do you want to load index.html using static content conventions? You should use the view location conventions and render the view using View from your route. The build in view engines, the SuperSimpleViewEngine, supports outputting .html files
From the top of my head I cannot say why the static content convention doesn't work with the root directory, but if it doesn't then that's definitly a bug. My guess is that we probably have some code that tries to determine if it the paths are invalid and exits early and that code it too strict
|Re: Loading static content( index.html) from root||Andreas Håkansson||3/23/12 1:13 AM|
There is indeed a bug in the StaticContentConventionBuilder.AddDirectory method. Have a fix, just need to wake up to make sure I'm not breaking anything else :P
|Re: Loading static content( index.html) from root||Sergey Shteyn||3/23/12 6:49 AM|
I have been using static context convention because it was the easiest to setup for my folder structure. From my root folder I have multiple app folders. I can access each app folder with the by calling localhost/app1/index.html and all the app's content is isolated within it's app folder. See structure below:
What I recently needed to do so to make rootapp as the root url (localhost/index.html or localhost) .
|Re: Loading static content( index.html) from root||Sergey Shteyn||3/23/12 8:10 AM|
Please let me know when the but will be fixed and if you need help in verification.
So i'm going to be able to do something like this after the fix?
How would a specify the requested client path that is at the root of the url?
|Re: Loading static content( index.html) from root||Andreas Håkansson||3/24/12 3:59 AM|
Yes the fix will let you do either
U haven't decided on which yet.. need to give it some thought.. I think the latter is more obvious on how the mapping will work.
|Re: Loading static content( index.html) from root||Prabir Shrestha||4/14/12 5:15 AM|
Has this been fixed yet?
This is a very good trick to organize the files in the project. I could create a "public" folder containing favicon.ico, apple-touch-icon.png, crossdomain.xml, human.txt, robots.txt and not clutter all these files in the root project.
|Re: [nancy-dev] Re: Loading static content( index.html) from root||Andreas Håkansson||4/14/12 5:28 AM|
There is a pending pull request for this, created by me, but I am not sure we'll put it into 0.11 in it's current shape. Probably not to be honest. It introduces a breaking change we'd like to avoid and I need to revisit it to see what kind of behavior we can modify it to have. It's a critical thing and we do not want to rush it and end up putting something with a security vulnerability out there
I will have a look tonight and see what can be done
|Re: [nancy-dev] Re: Loading static content( index.html) from root||Andreas Håkansson||4/14/12 6:17 AM|
Just had an idea.. will be hacking at it tonight =D
|Re: [nancy-dev] Re: Loading static content( index.html) from root||Andreas Håkansson||4/15/12 9:56 AM|
Forgot I had dinner reservations last night ;)
Anyway, I just wanted to point out that the StaticContentConventionBuilder is not the only way to define static content conventions. The SCCB is just a helper class that encapsulates some helper logic to easily define static content conventions.
A static content convention is just a Func with the signature Func<NancyContext, string, Response> where the string parameter is the one of the requested resource. So you could wire up whatever conventions you wanted.
That said, I am going to try and solidify my idea tonight. The mrs is working the late shift and the kids are heading to bed in half an hour.. oh and I have red bull in the fridge ;)