In our dto that represents a table of contents node we added a property of type dynamic where all the content-type specific data would go. For example, for ordinances, the ordinance adoption date and direct url would go there.
This code works fine from within the project (dll) where the table of contents list is first created (`node.d` is the dynamic property)
`var ords = flatToc.Where(node => !node.d.hasChildren)`
However, from within our api controller, whose project includes a reference to our business objects project where the code above lives, that same exact line produces an error to the effect of “object does not have a hasChildren property”. Totally caught me off guard.
I was hoping to use dynamics more often in our api but now I’m reconsidering and may just stick with typed dtos.
Update: a little googling and I found these helpful answers on stackoverflow:
We generally use ExpandoObjects but for some unknown reason we were using anonymous types in the scenerio above. So it’s not a dynamic problem, it’s an anonymous type problem. Good to know!
I learned this the hard way.
We added health checks to ARR and coincidentally in the controller of the page it checks I was doing
HttpContext.GetOverriddenUserAgent().Contains() because 51 degrees was incorrectly returning False for IsMobileDevice whenever I set the overridden browser.
Requests from a browser or even powershell all have values for
GetOverriddenUserAgent(), but requests from ARR returned null.
Good to know! You can’t assume
GetOverriddenuserAgent() will not be null.
This is an update to my previous post: http://www.philipholly.com/post/64211668657/node-js-iisnode-prerender-io-phantom-phantomjs
- Windows 8.1
- Visual Studio 2013
- Git Extensions (including git bash)
Since I got a new work laptop, I needed to resetup my local websites.
This are the steps I went through to get a local instance of prerender.io up and running locally in a node.js server. Much easier than last time! I didn’t need to install phantom.js server first. That simplified a lot. And maybe because I have Visual Studio 2013 instead of 2012 installed things just worked. I don’t know.
- Download node.js for windows
- Run node.js windows installer
- Let it add node to your path
- Open Git Bash and navigate to the directory where you want to host your prerender server
- run Git clone https://github.com/collectiveip/prerender.git. Instructions are here: https://prerender.io/server
- Run npm install
- I got the error: Npm install failed: pyhton 2.6 or 2.7 is required to build
- Download python 2.7.6 Windows Installer: https://www.python.org/download/
- Run python installer
- Exit out of console
- Open a new git bash window and navigate to your prerender project
- Run npm install
- This time it should work - I did get one warning C4506 but it doesn’t’ look like it’s a showstopper
- That’s it! This time I didn’t have to install phantomjs server separately. Maybe last time I didn’t but I didn’t know that? I don’t know.
- Follow the instructions here: https://prerender.io/server to test if it worked
Not bad at all! Now I need to get prerender.io to run from IIS instead of node - so I need to install iisnode - which is now managed by Azure by the way!. We’ll see how it goes.
When creating and debugging http handlers and http modules in ASP.NET you may find that the code you write is not getting executed or you can’t set breakpoints because symbols could not be loaded for your document.
The reason is because Http modules and Http handlers are registered during application initialization and if your app is already running then that registration won’t happen again until the app (IIS worker process) is shut down and a new one is created.
Easy fix: Make sure you’re not debugging in Visual Studio, use Windows Task Manager to kill all your w3wp.exe processes (well make sure the process that your solution is running in is killed), set breakpoints, then start debugging.
I think the debugger can successfully attach itself during application initialization because a new worker process is created.
After installing Git Extensions on my new laptop I quickly found myself having to enter my password every time git talked to the remote hosted on BitBucket.
If you have the same problem of Git Bash or Git Extensions asking you for your password every time you can try this, which worked for me:
- Open the
.gitconfigin your home directory in a text editor like SublimeText or Notepad++
- in the
[credential]section make sure there aren’t extra
\characters escaping the double quotes.
So instead of
[credential] helper = !\\\"C:/Program Files (x86)/GitExtensions/GitCredentialWinStore/git-credential-winstore.exe\\\"
it should read
[credential] helper = !\"C:/Program Files (x86)/GitExtensions/GitCredentialWinStore/git-credential-winstore.exe\"
Hope that helps!
So I got a new computer for work (Macbook Pro 13” retina) and needed to get it up and running as my new dev machine.
In my first attempt everything worked except Visual Studio 2013 wouldn’t launch. It was stuck at a white splash screen. It could have been because I installed IIS, then Visual Studio 2013, then I did a IIS Server Import from a Server Export of my old computer. Only after that did I try to run Visual Studio.
In my second attempt, after reinstalling windows and starting over, Visual Studio worked, but IIS didn’t work properly. As you’ll see in the steps below, I used IIS web deploy backup server / restore server to copy ALL my IIS settings (app pools, certs, sites, etc) but ran into a lot of problems. I kept getting a INSUFFICIENT_ACCESS_TO_APPHOSTCONFIG error, which seemed to indicate there was a permissions problem on applicationhosts.config, but in reality there wasn’t. The problem was my encryption keys in applicationhosts.config. I only realized that after trying to manually add an App Pool. Adding the App Pool worked fine, so the config file could be written to. But when I tried to change the App Pool user to a local user, which requires a username and password, I got the insufficient access error again with a sub message about something being out of bounds. User passwords get encrypted so I realized the encryption was the problem.
In my third attempt, after uninstalling IIS using Windows Programs and Features and uninstalling everything that I installed using Web Platform Installer and reinstalling IIS, everything worked. Both IIS and Visual Studio 2013 worked. I can start to code again!
Steps that worked for me
- Install Windows
- Turn off UAC by suppressing all notifications
- Using Programs and Features, add Windows Components, Install IIS. A quick way to get to the screen is Win+X (on windows 8) then select Programs and Features or type ‘f’. I recommend installing more than you may actually need because if you web deploy import server from another computer that has a component installed but you don’t you’ll get an error. Under Web Management Tools: IIS Management Console. Under World Wide Web Services: everything.
- Install Visual Studio
- Using Web Platform Installer, install any IIS components you may need, such as Web Deploy 3.5, URL Rewrite, PHP, PHP Manager, IISNode. I went ahead and installed ones for IIS Express as well just in case I need them. Make sure IIS is selected in the Web Platform Installer options so you can see the IIS components. For some reas IIS Express was selected for me.
- Add any local users you may need as users for your IIS App Pools. If you don’t use actual users in your app pools then you can skip this step. Since some of our web apps need network resources we had to add local users that can authenticate on the network resources. I’m not sure if any built in accounts can authenticate on network resources. If you do things this way, be sure to set your website to use pass through authentication (app pool user) and your anonymous authentication to Application Pool Identity.
- Now, the fun part. To get your IIS app pool and site configurations and site content off of your old computer there are a few options. As mentioned already, I first tried using IIS Export Server then IIS Import Server but ran into complications. Even if that worked, one thing I didn’t like about that was that it includes all your site content (your actual files and folders for each web site). I would rather transfer those independently. A few of my personal sites are run from my Google Drive folder and my other work sites are all in Git so I want to transfer those myself.
- Transfer all your site content. I let Google Drive handle the sites that are on Google Drive and I used a portable external hard drive to transfer my other work sites. I have them all under a Project/Git folder. Git is so great - because it’s all file-based, including the repos themselves, once you transfer everything you can start working immediately with your repositories and configs in the exact same state.
- Install Web Deploy 3.5 using the Web Platform Installer if you haven’t already.
- We want to install Web Deploy Remote Agent Service as well. The only way I found how to do this was to use Program and Features, select Microsoft Web Deploy 3.5, then click Change. When prompted click change, then be sure to select Remote Agent Service. There’s another component in Web Platform Installer called Web Deploy for Hosting Servers - that may turn that on automatically - but I’m not sure.
- Now, from your old computer, we want to push all the application pools to your new computer. Using Web Deploy takes care of all the encryption/decryption for you. And you can transfer all the app pool settings in just one line!
- Make sure Web Deploy 3.5 is also installed on your old computer. Open up an administrator command prompt (that’s in the Win+x menu too!) and navigate to (on a 64-bit machine) C:\Program Files\IIS\Microsoft Web Deploy V3. Web deploy will only work if the bit-ness of the source and destination match - so 64-bit to 64-bit and 32-bit to 32-bit. Presumably most computers, especially dev computers, will be 64-bit.
- The command to transfer all the app pools is:
msdeploy -verb:sync -source:appPoolConfig, -dest:apPoolConfig,computerName=NameOfNewComputerHere. The reference for the syntax is here: http://technet.microsoft.com/en-us/library/dd569070(v=ws.10).aspx
- Now we want to transfer each site individually. The web deploy provider I used, appHostConfig, is supposed to transfer content as well as configuration. I didn’t know that when I used it, and I can’t verify it transferred content. The command executed so fast I would be surprised if it also transferred content.
- For each site, use this command:
msdeploy -verb:sync -source:apphostconfig="website name" -dest:apphostconfig="website name",computername=NameOfNewComputerHere. I just looked at my site list in in IIS and after each command hit the up arrow and used the arrow keys to replace the website names. Syntax reference: http://technet.microsoft.com/en-us/library/dd569080(v=ws.10).aspx
- If you use local hostnames, then copy over your
- Install Git
- Copy over .gitconfig that’s in the root of your home directory - for me it was my windows home directory (Users/username).
- Webmatrix - copy over site configuration -
- Webmatrix - copy over IIS Express sites - if you don’t do this then no sites will show in “My Sites” - copy all the
That should do it!
That’s a .NET context object - but I think you get the idea. Just make sure you add the “Access-Conrol-Allow-Origin” header to the response.