IIS 7 - config error - duplicate add 'nancy' in system.webServer - WIN 7 Pro - localhost

Jan 1, 2014 at 6:12 AM
This is on a WIN 7 64bit localhost implementation, bDB is installed as a Service.

In C:\Program Files\BrightstarDB\Webapp\web.config - in the system.webServer section
22: <handlers>
23: <add name="Nancy" verb="" type="Nancy.Hosting.Aspnet.NancyHttpRequestHandler" path=""/>
24: </handlers>
and other entries in the Webapp-web.config show the bDB is embedded and points to the samples app DATAstore folder C:\Program Files\BrightstarDB\Data\

BrightstarDB Service is automatic and started.
All good.

__Trying to use bDB as an IIS 7 implementation, I did the following in IIS 7.5 Manager:
created an app:__
  • (1)(bDBwebapp) Physical path: C:\Program Files\BrightstarDB\Webapp Virtual Path: /bDBwebapp
  • under it a Virtual directory: (2)(bDBwebapp) same Physical and Virtual Path
  • a (3)(bDBwebapp) Folder appeared under the Virtual directory.
Each bDBwebapp entry in IIS 7 has a corresponding 'Browse' option on the rightclick Manage App, Manage Virtual Folder, Manage Folder menus.

if I browse the APP: I get page http://localhost/bDBwebapp with a [Home] button which responds to hovering of the mouse, and does nothing on click, except adding a # to the URL http://localhost/bDBwebapp# then it says BrightstarDB: Stores, Stores available on this BrightstarDB server, and a [Store] button which also responds to hovering of the mouse but does nothing on click.

If I remember correctly, I had gotten the same behavior when I first pulled the page up before trying IIS, but not sure, this could all be due to having created the IIS web site!

if I browse the VIRTUAL FOLDER or the bDBwebapp folder under it, I get the error, listed at the end of this post.

Question:
Could it be as simple as: in C:\Program Files\BrightstarDB\Webapp\web.config under the system.webServer section can I rename the handler named 'Nancy" to 'NancyServ'(see error below) and forge on to attempt to run bDB under IIS concurrently with the Service Installation without affecting anything(else) on the Service-Installation? or is this an uninstall/reinstall deal?

(I could test it, but I am afraid to demolish something in the 7 or 8 config files that can get affected by a change in IIS 7, and create a cascade of problems!)

...and if they cannot be run concurrently, how do I go about removing and/or turning off the service implementation, so the IIS setup becomes possible?

__------------------------------------------------------------------------
ERROR CLUES: (0x800700b7)
------------------------------------------------------------------------__
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.

Config Error: Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'Nancy'
Config file: \?\C:\Program Files\BrightstarDB\Webapp\web.config

Request URL: http://localhost:80/bDBwebapp/bDBwebapp/views/sample.html
Physical Path: C:\Program Files\BrightstarDB\Webapp\views\sample.html

22: <handlers>
23: <add name="Nancy" verb="" type="Nancy.Hosting.Aspnet.NancyHttpRequestHandler" path=""/>
24: </handlers>

The Error Code: 0x800700b7 on the 'more information link' of Microsoft, topic 3 and 6 may or may not come into play: http://support.microsoft.com/kb/942055
Coordinator
Jan 2, 2014 at 3:41 PM
I think it should be fine to just rename the handler, but I'm not sure what else it is clashing with unless perhaps you had an earlier release of BrightstarDB installed and have some how ended up with two Nancy handlers declared in the web.config (or maybe in a web.config at a higher level in the site?). Looking at the URL you have (http://localhost:80/bDBwebapp/bDBwebapp/views/sample.html) it does look like you have a bDBwebapp application inside another one, which would probably be the root cause of the error message.

I realized that there wasn't a quick "how to" on running BrightstarDB under IIS, so I've written one up. There are basically three things that are important:
  • The application pool should be a .NET 4.0 app pool with Pipeline Mode set to Integrated
  • The application pool user must have full control over the stores directory (assuming you are using an embedded BrightstarDB connection in the web.config file)
  • Make sure that the stores directory used by your web application BrightstarDB is not also being accessed by another BrightstarDB application (such as the windows server)
You can find the guide in the latest version of the docs (http://brightstardb.readthedocs.org/en/latest/BrightstarDB_In_IIS/)
Coordinator
Jan 2, 2014 at 3:44 PM
Reading your post again I think this is the problem:
__Trying to use bDB as an IIS 7 implementation, I did the following in IIS 7.5 Manager:
created an app:__
  • (1)(bDBwebapp) Physical path: C:\Program Files\BrightstarDB\Webapp Virtual Path: /bDBwebapp
  • under it a Virtual directory: (2)(bDBwebapp) same Physical and Virtual Path
  • a (3)(bDBwebapp) Folder appeared under the Virtual directory.
Each bDBwebapp entry in IIS 7 has a corresponding 'Browse' option on the rightclick Manage App, Manage Virtual Folder, Manage Folder menus.
There should only be one bDBwebapp entry in IIS for the application, you don't need to also have a virtual path. I would delete both of these from IIS (this will only delete the configuration from IIS it won't delete the files) and then try again following the instructions I provided a link to above.
Jan 5, 2014 at 6:29 PM
Edited Jan 5, 2014 at 6:36 PM
Thank you... I had already done all what you mentioned... including disabling the bDB Service.

It is just that years back, I had a conversion from IIS 6.x to 7.x in which I had lost patience trying to figure out the usual cascade of errors I faced on install, thus I was using the Visual Studio(2010) Internal Web Server, and decided this time I would bite the bullet and resume a proper IIS configuration as exists on my ISP HOST, as well as to satisfy the requirement for iisnode.

Not my preferred approach in resolving issues, but I ended up having to turn off the UAC on my dev WIN7 Pro machine and had to reinstall IIS 7.5 to clean up most of the errors... I also had to disregard the fact that the Microsoft IIS instructions for 7.x state that at least 1 app must exist per site and 1 virtual directory per app... Thus now I have my 3 apps(which I regard as separate web sites) under the Default Web Site, [bDB, node, MyApp, and nothing else.]

I do not publish to the inetpub hierarchy, instead I point the virtualPath to the dev folder of that app(Basic Settings). It saves massively repeated steps in development.
Of course I make sure to backup the dev side since I don't have the IIS hierarchy to save me in case of mishap!

The browse options on the right-click of the app in IIS now bring up the apps(sites) correctly. 'http://localhost/bDB'(virtual__Path__Name), or 'http://localhost/node', etc. the physical path obfuscated. NOT adding a Virtual Directory as I was doing before.

I can poke the URL directly into the Browser's address bar as well: ex: 'http://localhost/bDB' and the apps come up as expected.
  • Visual Studio choked on the setup of IIS as Web Server, I have had to let it create a bogus virtualFolder then delete that in order to get around a few errors it spat out.
All good. I am now on IIS. But the cascade of errors/issues is still not at an end.
  • Visual Studio now always warns: "The Web project 'MyApp' is currently configured to use the URL 'http://locaohost/MyApp'. The Web Server has this URL mapped to a different folder(DUHHH! the physical path) 'C:......\MyApp'. Would you like to remap this URL to point to this Web project's folder?"
    I click no... and go to work. I have not yet tried to interpret what the message really tries to convey! I don't see any incorrect settings in VS or IIS... it all works as expected... I made changes to test and verify the proper file hierarchy is the one addressed.
    @#$%@? OK... I can live with that, the cascade of issues has now at least been narrowed down to the App level.

  • Webapp (bDB app) brings up a BrighstarBD Stores page with 2 buttons on it: Home, and Store... and upon clicking either of the 2 buttons, nothing happens, except that the Home button adds a '#' bookmark character to the URL. Is that the expected behavior?, until data is added to the store? via the Service client tools provided?

  • after looking at your new instructions on IIS, under 5. Set Directory Access Privileges
  • in step f: I don't see the screen shot you refer to: "The result should be something like shown in the screenshot below."
  • in step e: "If the application pool is set to use AppPoolIdentity, enter the name of the user as IIS AppPoolApp Pool Name" on the C:\Program Files\BrightstarDB\Data Folder properties SECURITY TAB setup... I see no USER of that name... IIS_IUSRS is what I use for web access?! I guessed at a translation to IIS bDB DefaultAppPool of course that failed... as USER NOT FOUND... I am sure somewhere in the LSP the AppPool is set to IIS_IUSRS... I am at a loss on that one. It appears I don't need it.

  • on running the DATAstore concurrently (not at the same time, I assume) under the Service setup and the now working IIS, I am unsure how to proceed.
    changing the connection string from embedded to rest, would mean duplicating the project and set one up with embedded, the other with rest? ...and the Service need not be turned off when using IIS?
    I think I answered part of that one once I saw the BrightstarService.exe.config ...looks like the Service can be left alone, as embedded since it has its own config file.
  • <brightstarService connectionString="Type=embedded;StoresDirectory=C:\Program Files\BrightstarDB\Data\">
  • ...and the IIS/Webapp web.config set to - <brightstarService connectionString="type=rest;endpoint=http://localhost:8090/brightstar"> and that failed...
The port of the Default Web Site is 80. I tried 80/8090 brightstar/bDB in all possible combinations... no cookie! the endpoint is not in sync?!
Something else must be needed, as in doing a second installation of bDB as an IIS setup! (in a different Folder hierarchy)
or is it a matter of just creating a Web Site in IIS (bDBsite/bDB) with port 8090 forced?!
Also, can the port not be omitted and let IIS elect a port automatically? especially when this is deployed to the HOST?!

Error Details
Nancy.RequestExecutionException: Oh noes! ---> BrightstarDB.Client.BrightstarClientException: HTTP Transport Error ---> System.Net.WebException: The operation has timed out
at System.Net.HttpWebRequest.GetResponse()
at BrightstarDB.Client.BrightstarRestClient.AuthenticatedGet(String relativePath)
--- End of inner exception stack trace ---
at BrightstarDB.Client.BrightstarRestClient.AuthenticatedGet(String relativePath)
at BrightstarDB.Client.BrightstarRestClient.ListStores()
at BrightstarDB.Server.Modules.StoresModule.<>c__DisplayClass5.<.ctor>b__1(Object parameters)
at CallSite.Target(Closure , CallSite , Func`2 , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
at Nancy.Routing.Route.<>c__DisplayClass4.b__3(Object parameters, CancellationToken context)
--- End of inner exception stack trace ---
at Nancy.NancyEngine.InvokeOnErrorHook(NancyContext context, ErrorPipeline pipeline, Exception ex)

  • Not being able to bring up one of the projects in solution explorer makes it rather difficult to inspect the samples and get clues from that, since my C# feature was removed in my VS. I won't be able to work with that until I reinstall... and I dread that, I have made massive adjustments to my VS, if that gets demolished, I am yet deeper in the never ending cascading errors/issues nightmare. If I attempt to load a project in VS (C:\Program Files\BrightstarDB\Samples\Server\NerdDinner\BrightstarDB.Samples.NerdDinner\BrightstarDB.Samples.NerdDinner.csproj) I get the following error:
    --- The project type is not supported by this installation ---
I attempted to just look at the samples and do a quick conversion to VB of at least a basic piece of it and low and behold this stuff is in a RAZOR format, could not even figure out how the 'BrightstarDB Stores' page comes up, as no reference I could readily see(config) points to that page.

WOW! I knew I was going to be put thru the WWWringer trying this new toy! no am not going to scream bloody murder, just state it!
Thanks for any help.
Coordinator
Jan 6, 2014 at 7:27 PM
Oh I know this pain - being in the middle of cascade of errors.

OK, so working (sort of) backwards. The fact that you are able to get a page in your browser indicates that the IIS configuration is reasonably good - otherwise you would probably have all sorts of other yellow screens of death or in Nancy-land "Oh Noes". The fact that it then all times out horribly when trying to create a store and the error stack trace indicates to me that you have your IIS web app configured to connect to your Windows Service and that probably the Windows service is either (a) turned off or (b) just not functioning properly.

The permissions you need to set for the app pool: I'm pretty sure this is the same on Windows7 with IIS 7.5 as it is on Windows8, but they changed the default identity of app pools so that if the identity is callled "AppPoolIdentity" in the IIS configuration it is actually a user in a special domain called "IIS AppPool" where the user name is the same as the app pool name. So you need to look at the name of the app pool, and use that to get the user name that you should use). And no, none of these users show up in the IIS_IUSRS group, its a completely "magic" string that should just work. For more information about this and about security for directories and other resources, please take a look at http://www.iis.net/learn/manage/configuring-security/application-pool-identities - they have all the screenshots without missing stuff out :-)

Also, at this point I think the logical way out is to ask yourself - do I really want to run B* both as a Windows service and in IIS ? I really cannot see what you gain by doing that over just running the whole thing through IIS. So my suggestion is to ignore the Windows service (go into the Services part of the control pane and set its startup to Disabled just to be on the safe side), and then change your IIS web.config so that the connection string is changed to:
<brightstarService connectionString="Type=embedded;StoresDirectory=C:\Program Files\BrightstarDB\Data\"> 
The thing about having both with the same configuration is that you don't want them both to be running concurrently servicing requests, because both will think they have control over the files and they will at some point lock each other out of the stores you want to access. Note that once a service is up and running it may well hold a write lock on a store file for a while even if no requests are being made, because the nature of the architecture is that an embedded connection to BrightstarDB always assumes it is the only process accessing those files.

Now you should be good to go with the browser just pointing to the address you used to get the Oh Noes - and hopefully this time you won't get the error messages.

To come back to the Nerd Dinner example, this is an MVC app built on top of BrightstarDB, so the error you are getting from VS tells me that you don't have MVC 4 support enabled in Visual Studio. If you are on VS2010, you need to install some stuff which you can get by going to http://www.asp.net/mvc/mvc4 and scroll down on that page to the section "Install ASP.NET MVC 4 for Visual Studio 2010" (note that it requires you to be on VS2010 SP1. My feeling is that if you don't want MVC4 for other reasons, this is probably a step too far and I would recommend that you don't worry too much about it. Its a pretty basic sample app and for VS2012 folks MVC 4 is already installed so it works nicely I have no idea even if VS2010 will work properly with the solution file even after you have MVC 4 installed.
Jan 9, 2014 at 8:14 AM
You have been more than patient and accommodating to my rough start, and I am very appreciative.
As I am battling this evil plus the misconnects in instructions, ...the song that comes to mind... Say something...am giving up on you~
Be that you might seek the piece, here are the key words to search for: "A Great Big World(original)", also Christina Aguilera, Alex & Sierra

To be clear: the BirghtstarDB Service is DISABLED in the Services manager... I have rebooted several times, it never loads.

in C:\Program Files\BrightstarDB\Webapp web.config, you advised to use the embedded option, although I believe that in the end I will more than likely use a REST type, I am not sure where I read that it would be my option... but for now I just want to follow your advice to get this thing up and running.
thus:
  <brightstarService connectionString="Type=embedded;StoresDirectory=C:\Program Files\BrightstarDB\Data\">
NOT:
 <!-- brightstarService connectionString="type=rest;endpoint=http://localhost:80/brightstar" -->
(in my previous post) - The Brightstar's Stores Page comes up in the browser but the buttons do nothing... except for the behavior mentioned.

The instructions for IIS under (e.) are not clear to me. If I type in what is stated in the first line of e. ... I get user not found. and as I read further I see that I have to combine the first line with the last line under e. ...and that bit as stated(no slashes) did not help me to understand what to type in 'Enter the object name to select' in the ADD dialog.

so I searched for more info ... and found this post the only one that seems to match my issue, even though on different OSs.

at: TEXT
you will see the following:

'I' is NOT me here... this a post from someone else
Hi. I am using Windows Server 2008 [Version 6.0.6002]
I am using ApplicationPoolIdentity for my DefaultAppPool in IIS7.
  1. Now I go to www root folder, do right click - properties.
  2. Go to Security tab, click Edit, Add.
  3. Object Types are "Users, Groups, or Built-in security principals"
  4. "From this location" is local PC (not domen controller)
  5. "Enter the object names to select": "IIS AppPool\DefaultAppPool"

I am on WIN 7 not 2008 as above mentioned, but everything matches
I type: "IIS AppPool\DefaultAppPool" in box 5. and accept that, the user DefaultAppPool now appears in the USERs permissions list for this folder,

I have no idea that this is what the system is needing... I increased the permissions to that USER to FULL CONTROL... result, no difference!
Jan 9, 2014 at 11:04 PM
UPDATE:
...have not even yet pressed the first key... as the EntityFrameworkSamples cs project is now in my Solution Explorer.

Don't know how everything will pan out, but for the first time I have a dBD project at my reach.

Will edit this post, once I have had a chance to play with it some...