Author: Derek

  • The issuer of the token is not a trusted issuer. [Beware of hidden characters]

    The issuer of the token is not a trusted issuer. [Beware of hidden characters]

    There are a lot of articles related to this error message, typically seen when trying to run an on-premise SharePoint provider-hosted add-in in a high trust configuration.  I know because I read all of them.

    For me, there was no (visible) evidence that the IssuerId in my web.config was different than the RegisteredIssuerName value of my Trusted Security Token Issuer entry.  I checked and rechecked it dozens of times.

    Finally I put some tracing in the the code to see what was actually being sent to the SharePoint.  The creation of the authentication token is in the TokenHelper.cs class in the IssueToken method (about line 778).  Line 796 is where it gets the issuer id value.

    token-helper-code

    Here’s the screenshot of our trace log file reporting out the value being read from the web.config.  Notice anything unusual?

    issuerid-hidden-character

    There are some warnings related to cutting-and-pasting the Certificate Serial number picking up hidden characters – but somehow our entry in the web.config for the IssuerId also got a hidden character inserted in.  The “??” is passed along as part of the issuer ID value and causes the mismatch.

    I manually retyped the line in the web.config, saved, and reran the app.  This time it came through clean with no errors simply because the values exactly matched.

    By all appearances the values were the same, but the hidden character caused them to be different.

    Add this to your checklist of things to review if you hit this error – hopefully it won’t take you several days like it too me and my team.

     

     

  • Page Layout not shown in Design Manager

    Page Layout not shown in Design Manager

    If you have created a custom page layout from Design Manager, it will have an .html extension.  When this file is uploaded to the _catalogs/masterpage gallery, an event receiver will convert the file to a matching .aspx page layout.

    However, I found a case where the .html file will not show in the Design Manager as you would expect.

    I’ve been using the Patterns and Practices console application method for deploying branding assets, and it is a great way to push your branding related files up to a target SharePoint site.  However, in the UploadPageLayout() method, it is assigning all files that are uploaded with the Page Layout content type.

    If you use this against a .html file, it will upload fine, and will generate the .aspx file, but the .aspx will not be published, and the page layout will not be shown in Design Manager.

    I’ve adjusted the SetPageLayoutMetadata() method as shown below to properly set the .html file with the Html Page Layout content type, which will allow it to be seen in the Design manager – as well as ensuring that the corresponding .aspx is published.

    private static void SetPageLayoutMetadata(Web web, File uploadFile, string title, string publishingAssociatedContentType)
    {
      var parentContentTypeId = "0x01010007FF3E057FA8AB4AA42FCB67B453FFC100E214EEE741181F4E9F7ACC43278EE811"; //Page Layout
    
      if(uploadFile.Name.ToLower().Contains(".html")) {
        parentContentTypeId = "0x01010007FF3E057FA8AB4AA42FCB67B453FFC100E214EEE741181F4E9F7ACC43278EE8110003D357F861E29844953D5CAA1D4D8A3B"; //Html Page Layout
      }
    
      var gallery = web.GetCatalog(116);
      web.Context.Load(gallery, g => g.ContentTypes);
      web.Context.ExecuteQuery();
    
      var contentTypeId = gallery.ContentTypes.FirstOrDefault(ct => ct.StringId.StartsWith(parentContentTypeId)).StringId;
      var item = uploadFile.ListItemAllFields;
      web.Context.Load(item);
    
      item["ContentTypeId"] = contentTypeId;
      item["Title"] = title;
      item["PublishingAssociatedContentType"] = publishingAssociatedContentType;
    
      item.Update();
      web.Context.ExecuteQuery();
    }
    
  • How to Use Cortana to control your Hue lights

    How to Use Cortana to control your Hue lights

    For Raleigh Code Camp this year I thought I’d stay in the realm of IoT, but also bring together some latest and greatest sweetness.  So my talk is titled “Hey Cortana, turn on the lights” and is a fun walkthrough of using Cortana, Universal Windows apps on Windows 10, the Azure Service Bus, and the Hue API to control your lighting with your voice.

    Here are all the reference articles I used in preparing the talk, and the slides, code, and video will be posted after the event.

    https://www.instructables.com/id/Use-RPi-Azure-and-Cortana-to-Automate-your-Home/?ALLSTEPS – this article was my inspiration and provides a good overview of the various elements of this solution.  I updated for Windows 10, and did not use a Raspberry Pi (though now with the RPi 2 and Windows 10 IoT Core it would not be that difficult.)

    https://talkitbr.com/2015/07/13/integrando-a-cortana-em-seu-aplicativo-windows-10/ – this one is in Portuguese, but still shows how to structure the Voice Command Definition file.

    https://dev.windows.com/en-us/speech – the official page for the Speech SDK from Microsoft

    https://msdn.microsoft.com/library/windows/apps/xaml/mt185598.aspx – Cortana Interactions – good overview with example for adding VCD to your Windows 10 app

    https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/CortanaVoiceCommand/cs/AdventureWorks/Common – this is a sample project provided by Microsoft.  It seemed slightly out of date, but was a good reference.

    https://www.visualstudio.com/products/visual-studio-community-vs – Download page for Visual Studio 2015 Community edition.  You need VS2015 to do universal app development

    https://www.developers.meethue.com/ – the Phillips Hue developer site.  To get access to the full API docs you’ll need to register, but they have a getting started page here as well.

    https://github.com/Q42/Q42.HueApi– a .NET wrapper for the Hue API.  I didn’t use this directly, but modeled my own wrapper after it, and found it helpful for some of the JSON handling.

    https://azure.microsoft.com/en-us/documentation/articles/service-bus-dotnet-how-to-use-topics-subscriptions/ – article with code samples for interacting with the Azure Service Bus as a publish and subscriber

    https://blogs.recneps.org/post/Raspberry-Pi2-Iot-Core-and-Azure-Service-Bus – example of using the Service Bus REST api since the full SDK is not yet available for Windows 10

    https://msdn.microsoft.com/en-us/library/azure/hh690922.aspx – how to send messages using REST to the Service bus queue

    https://azure.microsoft.com/en-us/documentation/articles/service-bus-queues-topics-subscriptions/ – another overview of the Service Bus with code samples

     

     

  • Netduino Chicken Coop

    Netduino Chicken Coop

    This past year I designed and built some automation for our backyard chicken coop.  Here’s a video of me presenting the solution at the Raleigh Code Camp.

  • How does co-editing work in SharePoint 2013?

    How does co-editing work in SharePoint 2013?

    This week I was on site with a client discussing how to further leverage SharePoint in their business, and our conversation came around to how to better equip their field engineers and staff.  Specifically, I shared about the document library Sync feature.  One question came up regarding how SharePoint will reconcile changes if one employee modifies a file from their synchronized local copy, and another employee modifies the file directly from the Document Library.

    It’s a typical question and one I thought I’d answer using a live demo.  The video below illustrates how co-editing can work for both online and offline users.  I hope you find it helpful.

    (BTW: I’m going to try to start creating more of these kinds of Q&A videos, so if you have a suggestion for a question or explanation of a SharePoint feature, please comment on this post and share your idea.)

  • Letters to junior developers

    Letters to junior developers

    Dear Recent Graduate or Entry Level Developer,

    As someone who has been in the field you have selected for your career for some time, I hope you will allow me to offer some (completely unsolicited) advice about our industry.  I’ve been where you are: eager, motivated, and hopeful.  I’m sure you’ll encounter plenty of people who will have their own version of what I’m about to give you, but take them all together and just maybe something will carry with you in your career.

    Do this job because you love it

    Software developers like us certainly don’t corner the market on passion for our jobs.  But with passion can come great results.  I heard early on in my career the suggestion to “find something you love so much that you’ll do it for free, then become so good at it that anyone will pay you to do it.”  These days (compared to when I was in your position) being a programmer is a lot more trendy and mainstream.  Those who have passion will sustain – those who are just on the bandwagon will likely flutter off to some other interest.

    Learn to communicate

    Software is a unique product in that it reaches out to all levels of business and society.  In your job, you’re inevitably going to encounter customers, managers, and clients who may be executives and directors.  I’ve found that most of the time, particularly when things are not working as they should, these people want answers, not deep technical explanations.  Consequently, you need to learn to communicate effectively to lots of different audiences.

    One key element of learning to communicate is knowing how to balance discussion on technology and business.  Since in most cases, business rules the day (see below) you want to be able to engage with someone about their business, and also explain technology and its capabilities for them.  Sometimes this is as simple as asking “Would you like me to explain how this works?” rather than assuming they want to know.

    Additionally, effective communication comes by knowing and understanding the perspective of your audience.  If you are speaking to a business owner or department head, chances are they have a very bottom line view of the world, so you’ll need to learn how to discover those core values and then engage the person in that context.  In general, I find you’ll be much more respected, well received, and more likely to be invited back to the table when people feel like you can represent technology without making them feel overwhelmed or lost.

    Business rules the day

    With extremely few exceptions, you are going to work for an business.  That business is measured by a very simple equation:  revenues minus expenses equals profit.  Some organizations pretend that they are about other things, like serving people or changing the world.  But in truth they are measured by money.

    You will be hired to either increase revenues, decrease expenses, or facilitate both.  These two objectives will drive every decision, every meeting, and every opportunity that you will face.

    However, many of us (myself included) enter the industry without really understanding how business works.  We arrive, eager to write code and make something, never thinking that every hour we spend stuck on an issue is costing the company something.

    Therefore, I encourage you to get a basic education in business principles.  Understand the core principles of accounting.  Know how your employer keeps score, that is, what are the revenue centers, what are the cost structures, and how does your effort directly affect the bottom line.  To that point – know what the phrase “bottom line” really is talking about!

    You will inherit someone else’s code, and someone else will inherit yours

    In my parent’s generation, a worker would often stay with one company for their entire career.  In my generation, and likely for yours, this is no longer the case.  If you are on the same project or with the same company for more than 3 years, you may be the exception.  As such, the code you write and the code you are assigned will have lots of contributors to it.

    I say this because inevitably, the code you inherit will suck.  It will drive you crazy.  It won’t make sense, and you’ll long to be inside the head of the person who wrote it just to figure out what the hell they were thinking.  And then someone will feel exactly the same later on in life with the code you write.  If there ever existed an unspoken courtesy among programmers, it should be to try to make life easier for the next developer on the project.  This is at its simplest a longwinded way of saying “put comments in your code.”  But in the same way you’ll appreciate receiving those explanations, the ones who inherit the projects you have worked on will thank you.

    Learn to do things right, not just make them work

    One of the most cringeworthy statements I hear from developers on my teams when they get faced with a problem is something along the lines of “I just had to hack something together…”  Hack jobs are ticking time bombs.  A great deal of technical debt in the world is the result of hack jobs, done in a hurry, because someone didn’t want to take the time to do it right.  Resist this temptation as diligently as you can.

    If you feel caught between a problem and a deadline – go petition for more time.  Most managers and customers are reasonable enough to understand that a quick fix is often a seed that grows in to an expensive problem down the road.  Learn how to communicate that risk.

    Present a solution, not just a problem

    Finally, as a manager, you need to understand that I’m busy.  My day is full of lots of things.  So if you get stuck or have a crisis, just telling me about it adds one more thing to my plate.  Here’s the better way to do it:

    If you have a problem or are stuck on something that needs your manager’s attention, come prepared to explain the problem to them but also present your solution.  Let me know that you’ve put some thought to this.  You can ask for either my clearance to go do your plan, or a validation that your plan is reasonable and feasible.  But most importantly, demonstrate to your team or management your ability to solve the problem, and it won’t go unnoticed.

    Being a developer is a great job.  It’s fun, rewarding, and will provide you a good living. I know it has for me.  Go forth and code!

    Photo credit: Jeric Santiago

  • New SharePoint library not showing in Quick Launch after selecting Yes in Library settings

    New SharePoint library not showing in Quick Launch after selecting Yes in Library settings

    A client reported this issue to me this week.  They had added a new Document Library to a Team Site, and had assigned specific permissions to it.  However, it was never being displayed on the Quick Launch navigation.

    We checked the obvious things:

    1. Yes, the Display this document library on the Quick Launch? setting was set to Yes.
    2. Yes, the user had permissions to the site and document library.
    3. We hid and then displayed the Quick Launch using the Site Settings -> Tree View options.

    While initially we thought this might be some weird behavior in permissions, I came across this post that mentioned the Current Navigation settings for the site.  So I checked there.

    I found that the Current Navigation settings were fine, set to display the navigation items below the current site.

    What I also found, however, was that the Structural Navigation: Sorting option was set to Sort Manually.  When I looked in the list of items available for editing and re-sorting the navigation items, the new Library was not shown.

    navigation-sort

    So I flipped the setting to Sort Automatically, and voila, the library appeared in the Navigation items display.  As soon as I saved the navigation settings with the automatic sort, the library also appeared on the Quick Launch menu.

    It appears that if the manual sort option is in force, then it is based on a snapshot of the navigation items, and you’d have to manually add the newly added library to the Navigation hierarchy.

    Hope that helps someone out there!

  • RDU Code Camp 2014 – Creating a content strategy for your personal brand

    RDU Code Camp 2014 – Creating a content strategy for your personal brand

    This year’s Code Camp was a great success and I was honored to be selected as a speaker for a 2nd year in a row.

    In this session I talk about how to differentiate yourself in the marketplace by establishing and maintaining a personal brand.  We had some great practical discussion, and I appreciate all who attended and asked questions.  For those who weren’t able to join us, the video of the session is offered below.

    Thanks to all the sponsors and volunteers for this year’s Code Camp.  It was a great time to learn, meet new people, and be reminded of how strong the .NET development community is around the Triangle.

  • What’s New in ASP.NET Identity and other valuable lessons learned

    This month I had the opportunity to fulfill one of my goals for 2014 by presenting to the Triangle .NET User group.  This was a fun night with some great interaction.

    However, I learned a valuable lesson.  No matter how much you prepare, there will always be something unexpected.

    I always record my presentations.  I do this for several reasons.  First, it gives me the ability to share with the community and benefit those who can’t attend an event.  Secondly, I use them to learn and improve my own presentation style and skill.  Watching myself, getting over-sensitive about my verbal tics (you know?), and seeing how I interact with the audience are all things that help me get better as a speaker.

    This event was no different – I’d gotten to the venue early, made sure all my slides and demos were in order, and checked Camtasia to make sure recording would work on the projector (every venue is different.)  Everything was in order.  I felt great.  I was ready to go.

    The first half of the presentation was going smooth.  I felt like I was hitting all my key points, and was getting good questions and comments from the audience.

    Then I took a question I shouldn’t have.  I tried to say “let’s come back to this afterwards” but somehow I got persuaded to diverge from my flow.  And then I went to set a breakpoint in the demo code so we could see what was happening.  I did something I do dozens of times a day while coding.  But this wasn’t a normal coding session.  In this case, pressing F9 to set that breakpoint in Visual Studio did more than I expected.  I didn’t catch it in the moment.

    Visual Studio never got that F9 keypress, because Camtasia intercepted it.  And did exactly what it was set to do.  It stopped recording.

    I went on with the rest of my presentation, still feeling good, still interacting with the audience, still hitting all my points and nailing my demos.  But it wasn’t recorded.

    After the meeting that night, I was at home, reviewing the video of the session.  And then it just went black.  I realized immediately what had happened.  I may have said a few words in frustration.  I was deeply disappointed.

    Eventually I composed myself and realized the teachable moment I had before me.  The opportunity to encourage others to check for the unexpected hiccup in their preparation.  To remind others and myself that the best laid plans still are vulnerable to mishaps.

    It reminded me of something I try to teach my children – that sometimes we learn best through our mistakes.

    So here is the first 47 minutes of my presentation that night.  I trust that even in its abbreviated form, there is value in the content.  But be assured, next time, Camtasia won’t listen to any hotkeys.