<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Steve Peirce on Medium]]></title>
        <description><![CDATA[Stories by Steve Peirce on Medium]]></description>
        <link>https://medium.com/@srpeirce_67604?source=rss-f5ebf64b75bc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*LyCc8WXAbXYHpdzgzEyKvg.jpeg</url>
            <title>Stories by Steve Peirce on Medium</title>
            <link>https://medium.com/@srpeirce_67604?source=rss-f5ebf64b75bc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 14:23:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@srpeirce_67604/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[19 Tips for Software Engineers Who Become Managers]]></title>
            <link>https://medium.com/@srpeirce_67604/19-tips-for-software-engineers-who-become-managers-f46953b17b88?source=rss-f5ebf64b75bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/f46953b17b88</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[management]]></category>
            <category><![CDATA[leadership]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[management-and-leadership]]></category>
            <dc:creator><![CDATA[Steve Peirce]]></dc:creator>
            <pubDate>Mon, 13 Sep 2021 22:04:37 GMT</pubDate>
            <atom:updated>2021-09-13T23:00:43.491Z</atom:updated>
            <content:encoded><![CDATA[<p>Picture this; you’re an experienced software engineer who has just received a promotion or new job and you are now a manager — Whoohoo!!</p><p>Perhaps being a manager is your full-time gig, or [like me] it’s just 1 of your many responsibilities.</p><p>Easy right?!</p><h3>Line Management Is The MOST Important Part Of Your Job</h3><p>The importance of management is often underestimated — many of us just “wing it”, or worse, we prioritise our other work.</p><p>What happens to our team when we are a bad manager?</p><ul><li>The team becomes unhappy and unmotivated</li><li>The team is unproductive</li><li>It can bread a toxic culture including; fear, distrust and heroics.</li><li>All the good people leave</li></ul><p>Alternatively, what happens when we invest time and effort into management?</p><ul><li>The team becomes very happy and highly motivated</li><li>The team is highly productive</li><li>You’ve created a safe space for people to thrive, created a culture of sharing and collaboration</li><li>You have great people who encourage other great people to join the organisation</li></ul><p>But how do we get there? Management is a skill that can be learnt, but it takes deliberate practice.</p><p>These are some of the lessons that I’ve learnt</p><h3>What Is My Role</h3><p>I find myself pondering “what is the role of a manager?”.</p><p>I’m not sure I have a traditional view and see myself as</p><ul><li>A mentor — to help them solve any problems and keep progressing</li><li>A guide — to help understand the direction they want to move and keep them on course</li><li>An enabler — helping clear any obstacles and distractions that is getting in their way</li><li>An ally/supporter — Somebody who can assist or support through any problems</li></ul><h3>Weekly 1-on-1</h3><p>I try to have a weekly 30minute chat with each of my team (at least). It’s a great chance to catch up and avoid surprises.</p><p>Those 6 and 12 month reviews are a breeze when you have regular catch-ups and deliver constant feedback.</p><p>Occasionally I will miss a 1on1 due to sickness/holiday — no big deal, we caught up last week and we’ll catch up next week. Compare that to missing our bi-weekly or monthly 1-on-1, we’ve either scrambled for a new calendar slot or we miss it entirely.</p><blockquote>I’ve worked for multiple companies where 1-on-1s were very rare — you might be surprised that these companies were dysfunctional and had high churn rates of staff.</blockquote><h3>Get To Know Your Team</h3><p>Why bother getting to know your team members, shouldn’t we be focusing on the business?</p><p>I often find it fun and enjoyable getting to know everybody, I’ve found it helps to build trust which leads to more open and honest feedback, being more receptive to feedback, and just generally sharing more openly so you are able to offer support or help make plans.</p><p>I like to start 1-on-1s with a question unrelated to work:</p><ul><li>How was your weekend?</li><li>Did you have a nice evening?</li><li>How did your daughter get on at their first day of school?</li></ul><p>If somebody doesn’t want to talk about their home life then that’s fine, don’t push it!</p><h3>Don’t Do All The Talking</h3><p>Think of 1-on-1s as “their time” — it’s all too easy to do all of the talking and make this meeting all about ME.</p><p>As a general rule of thumb, I try to do at least twice as much listening as I do talking.</p><blockquote>For the record: Yes, I do struggle sometimes not to do too much talking. It’s good to try and catch yourself.</blockquote><h3>Don’t Put People On The Defensive</h3><p>Just imagine that you are struggling with your work, and you manager asks you these questions:</p><ul><li>WHAT are you working on?</li><li>WHY haven’t you completed this work, it seems to be taking a long time?</li></ul><p>If you are anything like me then you will instantly feel defensive. These seemingly innocent questions will engage my <em>fight of flight</em> reaction, meaning I am defensive and close down.</p><p>Try experimenting with other ways of asking:</p><ul><li>HOW are you finding the current work?</li><li>DO you need any help and support?</li></ul><p>If you are able to ask the same question in a way that doesn’t engage <em>fight or flight </em>reaction you will have a much more productive conversation.</p><blockquote>Just think how productive your last argument was when you felt really defensive, compared to the next day when everybody had calmed down.</blockquote><h3>Work Is Fine</h3><p>To be an effective manager it’s good to understand how your team members are getting on at work, are they finding the work engaging and interesting, are they enjoying working in the team, etc.</p><p>I will ask “How’s work?” and 90% of the time will reply “It’s fine”.</p><p>Eek that has closed the conversation. I’ve been experimenting for a while and find asking more specific questions can be helpful:</p><ul><li>How was that planning meeting for you?</li><li>Are you enjoying the current work?</li><li>Is there anything that would you like to see to make working here more enjoyable?</li><li>Would you be interested in learning more about xyz?</li><li>Do you have a favourite feature that you worked on recently?</li><li>How did you feel when we paused the in-flight work?</li><li>How did you find pairing with Lucy when you worked on that bug?</li></ul><p>Again, I recommend experimenting with how you phrase the questions and see what works for you.</p><h3>Don’t Be A Problem Solver</h3><p>There have been many times in that a team member has described a challenge or problem that they are facing. As their manager I want to help, so I will share the benefit of my experience and give them 1 or more solutions!</p><p><strong>Unfortunately</strong> I have just made a mistake, on this occasion my team member wanted to talk and wasn’t looking for my solution. In-fact, I have just annoyed them with my advice.</p><blockquote>Have you ever confided with a friend who offers you some unsolicited advice and tells you what you should do? Yes, me too! It’s annoying isn’t it! People often share problems and don’t want your advice, they just need to get something off of their chest.</blockquote><p>So what should I do instead?</p><p>Try asking if they need any help, or are they just looking for somebody to listen? If they are looking for help you could try asking if they have any ideas, and have they tried something already?</p><p>Sometimes your team members will want your advice but not your solutions. There’s a chance that they already have some ideas which they were hoping to talk through with you, but you’ve already derailed them.</p><p>Or sometimes they really don’t know what to do, maybe this is a chance to coach them through the situation by asking them questions to help them think about what they could do to resolve their problem. You might even provide them a tool for the future to break down problems and think of solutions!</p><blockquote>Tip: Don’t ask “are you looking for sympathy” as that has negative connotations and can provoke the <em>fight or flight</em> reaction</blockquote><h3>Life Comes First</h3><p>As you get to know your team members you sometimes have a glimpse of their lives. You learn about events that are happening, what is making them happy, what is making them sad, and what are the challenges they are facing.</p><p>Generally I follow the philosophy:</p><ul><li>Treat people like adults</li><li>Home life comes before work life</li></ul><p>Home life happens all the time and things come up — Perhaps somebody wants to start a few hours later so they can watch their daughter perform in a play, or to disappear in an afternoon to pick up their Mum from hospital, or perhaps they are sick and need to rest.</p><p>In all these situations I would say “it’s fine, just do it”. I will push back to anybody in the company who has a problem with this.</p><p>Good people can choose to work wherever they want, so please just treat people like adults.</p><blockquote>I worked for 1 company that had a production incident, I stayed past my 5PM finish until midnight. The next day I got to my desk at 9:10AM (10minutes late), I received a written warning for not being at my my desk on-time. I was not at that company for very long.</blockquote><blockquote>Compare to a different company where my Dad was in hospital, they insisted that I finish early every day to make sure that I have time to visit him. They offered me to work from home as required even though that wasn’t standard at the time. I still recommend this company as a good place to work.</blockquote><h3>Give Candid Feedback</h3><p>I find a lack of feedback super frustrating. I often hear statements like “I haven’t had any feedback, so I must be doing alright”.</p><p>And then when there is feedback people receive things like “They are doing great”. Okay that’s a nice comment, but it’s not really anything I can work with to improve.</p><ul><li>Have you ever worked in a team where somebody isn’t meeting expectations? <strong>But nobody has told them so they have no idea!</strong></li><li>Have you ever found yourself getting annoyed because of some mistake or behaviour that somebody constantly does? <strong>But nobody has ever shared this with them and they are oblivious to it!</strong></li></ul><p>I found the book <a href="https://www.radicalcandor.com/the-book/">Radical Candor</a> quite insightful for giving feedback.</p><p>I <em>try</em> to give immediate, honest and candid feedback, I’m still learning and practicing this everyday.</p><p>Just be sure to share any feedback privately!</p><p><strong>Immediate Feedback:</strong> Try and give feedback in the moment, whether that is grabbing somebody for 5minutes after a meeting or a message. Worst case give feedback in your weekly 1-on-1. The longer you leave it the more meaningless it is…”Do you remember that meeting last month….” — no, not really. I don’t limit feedback to just my team, I generally try and share with anybody :)</p><p><strong>Honest Feedback: </strong>Always be honest — if somebody wants feedback about something and you tell them “Everything was awesome” when really you are thinking “That was awful” then you have done the person a lot of damage. Also, when you are honest then people will build trust that when you say something was good that you genuinely mean it.</p><p><strong>Candid Feedback: </strong>always try to share your feedback in a constructive manner, we want to build an environment where everybody can share without fear of reprisal.</p><p>You can experiment with techniques of giving feedback, but a good starting point is the traditional <strong>Good Feedback </strong>&gt; <strong>Constructive Feedback</strong> &gt; <strong>Good Feedback </strong>[affectionately known as the “💩 sandwich”].</p><p>Here is an example of feedback that I might give for a presentation:</p><ol><li><strong>Good:</strong> Your content was very informative and you presented very well. I really liked the diagram that showed the overall process.</li><li><strong>Constructive: </strong>I found that some of the slides had a lot of text, I caught myself reading them instead of listening to you. :(</li><li><strong>Good: </strong>At the end of your presentation you answered the questions very clearly and concisely, I was especially impressed how you answered the question about XYZ.</li></ol><p>Sometimes constructive feedback is hard but people are generally looking to improve, so also offer nit-picks. I suggest explicitly calling out “If I was to be really nitpicky…”</p><h3>Request Feedback</h3><p>It’s really good to request feedback about yourself, how else are you going to improve? I often find people are hesitant to share at first — we’ve all had some managers at some point that do not foster a safe environment.</p><p>Eventually you will build some trust and start receiving some feedback. I always make a point of thanking people for sharing and being really excited/encouraging.</p><p>Be warned: at some point you will receive some feedback that will really hurt, try to stay calm and keep composed. If you become defensive or even aggressive you can really break the trust and they might not be as forthcoming with feedback next time.</p><p>If you are feeling emotional then it can be good to ask “If it’s okay I would like a little time to reflect on your feedback”.</p><h3>Don’t Be Rude About People</h3><p>Sometimes you will become frustrated or annoyed with somebody or with a group of people. It’s very easy to start moaning or being rude about somebody to your team members.</p><p>AVOID THIS AT ALL COSTS!!! It’s easy for people to start assuming “if Steve is moaning about Sam to me, then what’s he saying about me to Sam?”.</p><p>So what to do instead? Take a break, cool down, maybe talk to your own line manager to let off some steam.</p><p>When you are calm you can try and talk to the person/people that have frustrated you (see Feedback). Usually there is some learning or agreement that can be made to better work together…or sometimes it was just a moment that you can let pass and they caught you on a bad day.</p><h3>Unrest In The Team</h3><p>At some point, one of your team members is going to have an issue with another team member — we can’t all get along well all of the time.</p><p>So what do you do when this happens? I try to understand the problem, what has happened? Is this a new problem or something that has been building? Be sure to empathise with your team member, you can even thank them for sharing if it’s a difficult thing to raise.</p><p>When you understand the situation you can start to understand what is needed:</p><ul><li>Did they just need somebody to listen?</li><li>Are they looking for help/advice?</li></ul><p>Sometimes you can help craft the frustration into some retro feedback (if it isn’t too personal), other times it might be that you can help the person feedback and discuss directly, or sometimes as a line manager you can talk to the people involved.</p><p>Just be sure to handle these issues sensitively, and seek advice from your own manager as required (even if you anonymise some details).</p><h3>Don’t Burn Trust</h3><p>Treat anything that is said in a 1-on-1 with confidence.</p><p>I feel very honoured and privileged that people share all sorts of information with me, both about work and about their personal lives.</p><p>No matter how much you want to talk about something that somebody has said, NEVER EVER discuss without permission. It’s very easy to get this wrong and burn their trust.</p><p>If there is something that you feel you need to share, then please ask permission, e.g.</p><ul><li>Thanks for sharing, would it be okay to let HR know so we can offer some support?</li><li>If I anonymise this feedback, would you mind if I share it?</li><li>Am I okay to pass your comments on?</li><li>This is so cool, would you be interested in talking about it with the rest of the team?</li></ul><h3>Understand Ambitions and Drive</h3><p>One really cool thing about being a line manager is understanding people’s career aspirations and drive, and helping them make progress towards it.</p><p>As you start to get to know your team, take the time to find out what their aspirations are. You will have an interesting mix of people who want to take the next step (e.g. Mid to Senior), or others who have grand plans of becoming CTO or owning their own company.</p><p>If you are lucky then your company has some sort of “Progression Framework” that you can use to guide some of these conversations.</p><p>It’s all very well understanding aspirations, but do try to help create some action plans to help your team members see progress, and make sure that they have any resources and time that they need to learn. As a manager/leader you will sometimes need to campaign for more budget and time for your team members — be sure to do this!!!</p><h3>Sponsor People</h3><p>You’ve talked to your team and understand their career aspirations, and you’ve helped set out a plan. Often we can go an additional step and “sponsor” — this involves getting people a “seat at the table” to gain experience.</p><p>If you have team members who are interested in Solution Architect roles, then make sure that they have opportunities to help design upcoming features.</p><p>Maybe somebody wants to be a CTO, you can arrange for them to work with your CTO or pick up some CTO responsibilities over time?</p><p>If somebody wants to be a line manager then you can start getting them involved in the recruitment process, etc.</p><p>General idea: Look for opportunities to help your team grow. If you can’t offer them directly then talk to others on their behalf to get them invited.</p><h3>No Blame</h3><p>Has somebody deleted a production database, or deployed some bad code and caused an outage? No worries, it’s fine.</p><p>There are 2 facts of life in software development:</p><ul><li>We break things</li><li>We fix things</li></ul><p>Never punish people for innocent mistakes! Most people are going to feel awful for causing an outage, they don’t need you giving them a hard time, quite the opposite in-fact, you should be offering them support.</p><p>So long as we are learning and improving both as a team and as individuals then it’s fine — try and encourage a culture of learning from mistakes and taking proportionate actions to prevent them from happening again.</p><h3>Fail Publicly</h3><p>As a manager and leader I think it’s important to share your mistakes publicly. This is a good way of showing people “it’s okay” and helps foster that safe environment.</p><p>I have made various mistakes, including (and definitely not limited to):</p><ul><li>Writing SQL update statements and forgetting the WHERE</li><li>Deleting the wrong resources in production</li><li>Pushing a bad change to production then going home</li></ul><p>They are all embarrassing, but sharing is important and stops a culture of cover-ups.</p><h3>Experiment and Adapt</h3><p>Find what works for you and your team, and don’t try to force a strict structure.</p><p>I adapt my line management based on the needs and relationships that I form with each team member, each of my 1-on-1s has adapted over time and is completely different.</p><p>I propose that you experiment and reflect on what goes well and what doesn’t. At some point you will make some mistakes and upset somebody, try and recognise this, apologise, and learn from it.</p><h3>Thank You</h3><p>Thanks for reading. Please leave any candid feedback below.</p><p>Please share any of your own line management tips and tricks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f46953b17b88" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why We Chose Blazor WASM for our SPA]]></title>
            <link>https://medium.com/powered4-tv/why-we-chose-blazor-wasm-for-our-spa-c62524cde4a9?source=rss-f5ebf64b75bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/c62524cde4a9</guid>
            <category><![CDATA[blazor-webassembly]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <category><![CDATA[blazor]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[aspnetcore]]></category>
            <dc:creator><![CDATA[Steve Peirce]]></dc:creator>
            <pubDate>Mon, 14 Jun 2021 18:14:23 GMT</pubDate>
            <atom:updated>2026-06-03T14:41:54.930Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Update 3rd June 2026:<br></strong>Five years on, I went back and re-graded every prediction in this piece against .NET 10 — this time building <a href="https://mincalc.com/">MinCalc</a>, a daily-puzzle site, on my own. The follow-up is here: <a href="https://mincalc.com/blog/why-blazor-again">Why I Chose Blazor Again: Five Years Later</a>.</p><p><strong>Update 13th July 2021: </strong><br>I am lucky enough to have spoke on the ASP.Net Core Community Standup where I share more information. Check it out here: <a href="https://www.youtube.com/watch?v=hKxciQMxueI">ASP.NET Community Standup — Building with Blazor: Powered4.tv — YouTube</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bvv9JudltdIH_Up1BnsTBg.png" /><figcaption>Powered4.tv — Blazor WASM App</figcaption></figure><p><a href="https://powered4.tv/">Powered4.tv</a> is the UKs #1 video-on-demand site for independent wresting content, we feature hundreds of hours of content and over 50 channels.</p><p>We started in 2020 as a small team of 4 people, comprising of 2 .NET engineers and 2 business people. This was a side-project, meaning that everybody had limited time [due to working full time and <em>having lives</em> 😋].</p><h3>Developer Productivity</h3><p>Me [<a href="https://medium.com/u/830ccc8ae37b">Steve Richard Peirce</a>] and <a href="https://medium.com/u/b99631d1487f">Josh Dadak</a> are both .NET engineers who largely focus on distributed backend systems, this is our happy place! Choosing frontend tech was hard, so we decided to prioritise based on our own developer productivity.</p><p>Given our limited time each month and lack of day-to-day frontend dev work, we wanted our frontend tech to have structure, possibly an opinionated framework that would land us in the pit of success. We wanted to build MVPs and find market fit, not spend hours choosing between libraries, and configuring WebPack.</p><p>Our first choice was actually <a href="https://nextjs.org/">Next.js</a> — this is a framework built on top of <a href="https://reactjs.org/">React.j</a>s which offers loads of great features, including out of the box TypeScript support, server side rendering, and much more.</p><h3>But What About Blazor?</h3><p>Before going with <a href="https://nextjs.org/">Next.js</a> we thought about <a href="https://blazor.net/">Blazor</a> — this is .NET’s solution for Single Page Applications (SPAs) which is part of <a href="https://dotnet.microsoft.com/learn/aspnet/what-is-aspnet-core">ASP.Net Cor</a>e.</p><p>Blazor was appealing to us as it let’s you write SPAs with C# using all of the tooling we know and love (e.g. <a href="https://visualstudio.microsoft.com/">Visual Studio</a>, <a href="https://www.jetbrains.com/rider/">Rider</a>, or <a href="https://code.visualstudio.com/">VS Code</a>) and our familiar .NET libraries.</p><p>However, having followed Blazors progress I had concerns over its limitations and maturity — I expected it would be okay for an internal business application but perhaps not ready for a public facing site…</p><p>…still, it would be rude not to give it a try — after all; we are active members of the .NET community! 🙈</p><blockquote><strong>Aside: Hosting Models</strong><br>There are 2 hosting models for Blazor on the web; Server and WASM (short for WebAssembly).</blockquote><blockquote>You can find lots of talks and posts explaining the difference between the WASM and Server hosting models — we were mostly interested in WASM to keep costs lower by reducing load on our servers. There is significant download and performance differences, so be sure to read about both options.</blockquote><h3>Love At First Component ♥</h3><p>So we did it — we tried Blazor WASM…</p><p>After creating our first projects with dotnet new and being greeted with a basic working app, we were able to experiment and learn quickly. With prior experience in <a href="https://reactjs.org/">React.j</a>s, Blazor’s component model was very familiar and intuitive.</p><p>We found it was easy to add pages/components, and quickly became familiar with Blazor’s paradigms. We loved being able to use C# to write a web app!</p><p>Configuring dependencies is a breeze — they are configured exactly the same way as we are used to in a standard .NET application using Microsoft.Extensions.DependencyInjection. Missing some functionality? Easy, just pull in your favourite Nuget package!</p><p>Overall we felt super productive and fell in love with developing in Blazor.</p><h3>Trail-Blazors</h3><p>So back in 2020 [net3.1] we decided to go full steam ahead with Blazor WASM.</p><p>We knew that there were some big pain points that were going to cause us issues, but looking at the community excitement, the investment, and the upcoming Blazor Roadmap, we were super excited for the future of Blazor and made a decision that any pain points will be resolved [hopefully].</p><p>Worst case? We would port across to Next.js 🙈</p><h3>The Pain Points — June 2021 Review</h3><p>So after about a year of developing <a href="https://powered4.tv/">Powered4.tv</a> in Blazor, what were our pain points and have they been resolved?</p><p>In short, yes!</p><p>Well, largely!</p><p>There have been so many improvements this post will never do justice, but here is a brief summary of some that excited me.</p><h4>Pre-Rendering</h4><p>Pre-rendering is when the server renders the HTML server side, this is great for Search Engine Optimisation and providing a great customer experience.</p><p>Back when we started you needed to *botch* server-side pre-rendering (e.g. my article <a href="https://medium.com/@srpeirce_67604/server-side-render-blazor-client-side-app-wasm-efd3d9d12a6c">Server Side Render Blazor Client Side App (WASM) | by Steve Peirce | Medium</a>) — but this left a weird page flash which was not a nice experience for customers — everybody commented on it.</p><p>Fortunately, this has been resolved since .NET<a href="https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-preview-2/#preserve-prerendered-state-in-blazor-apps"> 6 preview 2</a> where we are able to preserve our pre-rendered state avoiding the loading flash. Check this out on <a href="https://powered4.tv/">Powered4.tv</a>.</p><h4>Performance</h4><p>Performance in Blazor WASM has always been slow when compared to a JavaScript app — we find start-up the biggest issue. Once the app has loaded it’s generally super fast for general use (e.g. navigating between pages). Right now you won’t get great scores in Lighthouse, but we cross fingers for the future.</p><p>We have seen continued improvements to the IL interpreter with notable gains upgrading from net3.1 to net5.0, and some gains upgrading to net6.0 previews.</p><p>There are now various perf tweaks available such as lazy loading dlls and js.</p><p><a href="https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-preview-4/">.Net 6 Preview 4</a> introduced AOT compilation — that means we can compile our code directly to WebAssembly instead of dlls being interpreted promising significant perf gains (in exchange for a slightly larger download).</p><p>Look out for a future post where we turn AOT on and compare differences in performance and download sizes!</p><h4>Other</h4><ul><li>Css/JS was difficult to manage — lucky for us .Net 5 introduced <a href="https://docs.microsoft.com/en-us/aspnet/core/blazor/components/css-isolation">CSS Isolation</a> and <a href="https://docs.microsoft.com/en-us/aspnet/core/blazor/javascript-interoperability/call-javascript-from-dotnet?view=aspnetcore-5.0#javascript-isolation-in-javascript-modules">JS Isolation</a></li><li>Some “basic functionality” missing — such as setting &lt;head&gt; elements including &lt;title&gt; and &lt;meta&gt; tags dynamically. Fortunately libraries such as <a href="https://github.com/jsakamoto/Toolbelt.Blazor.HeadElement">Toolbelt.Blazor.HeadElement</a> make it really easy.</li><li>Dev feedback loop was quite slow — when making a change to a component or style you would have to wait for the app to restart before seeing a change. As of <a href="https://github.com/jsakamoto/Toolbelt.Blazor.HeadElement">.Net 6 Preview 3 our prayers have been answered with Hot Reload</a>. Hot Reload will update the running application with your UI changes whilst keeping application state, and it’s ridiculously fast!!!</li><li>Testing has matured over the last year. With libraries such as <a href="https://bunit.dev/">BUnit</a> , <a href="https://github.com/VerifyTests/Verify.Blazor">Verify</a> and <a href="https://github.com/microsoft/playwright-dotnet">Playwright</a>, we can match the same testing strategies that any modern UI developer would expect.</li><li>Download Size — The smallest Blazor App is always going to be bigger than the smallest JS App. However, our site is an on-demand streaming site so we decided a slightly larger download is acceptable. Over the last year download sizes have reduced, and continued work with IL Linker that does tree-shaking to remove unused code from downloaded binaries.</li><li>Much more…</li></ul><h3>The Future Is Native Apps</h3><p><a href="https://powered4.tv/">Powered4.tv</a> is currently a Progressive Web App (PWA) — we can install the website onto a Phone/Tablet/Laptop straight from the browser. Installing a PWA adds a shortcut to Home/Start, and let’s you open the app without the browser — very nice.</p><p>But what if we wanted the app in the App Store for exposure/reviews/etc? Well we could bundle it up with the help of <a href="https://www.pwabuilder.com/">PWABuilder</a> [Other tools are available].</p><p>Apps running like this are still just Blazor running in the web browser — it is good, but can we do better?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oAWTUQ981Y33LiC1EPemQw.png" /><figcaption>Install Powered4.tv PWA</figcaption></figure><p>What if we could get the native device performance? If we could replace some controls with native UI? If we could easily hook into the native APIs for each device?</p><p>That’s where we’re hoping .NET MAUI can help us [coming in .NET 6] — where we get exactly that! We will be able to package our existing code into a native app to be submitted to the Apple, Google Play and Windows stores.</p><p>Checkout <a href="https://youtu.be/8xLw-f1iFLw?t=3300">ASP.Net Community Standup from 8th June 2021</a> to see it in action!</p><h3>Summary: Was Blazor the correct choice?</h3><p>1 year on and we are super happy with our choice. There are still a few rough edges here and there, but the rate of improvement is amazing.</p><p>New previews of .Net6 are coming out each month; with each new update I am more productive, and impressed with new features and performance improvements.</p><p>I urge you to try it out if you haven’t already!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c62524cde4a9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/powered4-tv/why-we-chose-blazor-wasm-for-our-spa-c62524cde4a9">Why We Chose Blazor WASM for our SPA</a> was originally published in <a href="https://medium.com/powered4-tv">Powered4.TV</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Blazor — Set Title On Server and Client]]></title>
            <link>https://medium.com/@srpeirce_67604/blazor-set-title-on-server-and-client-7fb4ed6ec607?source=rss-f5ebf64b75bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/7fb4ed6ec607</guid>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[blazor]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <category><![CDATA[aspnetcore]]></category>
            <dc:creator><![CDATA[Steve Peirce]]></dc:creator>
            <pubDate>Mon, 15 Jun 2020 05:01:28 GMT</pubDate>
            <atom:updated>2020-06-15T05:01:28.906Z</atom:updated>
            <content:encoded><![CDATA[<h3>Blazor — Set Title On Server and Client</h3><p>Use this technique for updating all meta tags too…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qo-dB6_bOXxWUwhP4Z5FRQ.png" /><figcaption>Adding custom Head component to set the Title and other elements</figcaption></figure><p>At the moment Blazor does not have any first party support for setting elements inside the &lt;head&gt; tags. For any customer facing site this is a must-have!</p><p>I’ve seen a few posts showing how to set the Title on the client, but none for the Server. Let’s address that now…</p><h3>TL;DR</h3><p><a href="https://github.com/srpeirce/Blazor-SSR/pull/1/commits/6d7e9616c0f3307b5f0c706fe316742245effe61">Code is here…</a></p><h3>Let’s start with Client Side</h3><p>Setting the title on the client is easy, we just need to call a small piece of JavaScript.</p><p>First create a new file, I’ve called mine Head.js</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*lF5s2_vDtMG9WPYLyvvkGQ.png" /><figcaption>Creating new JavaScript file — Head.js</figcaption></figure><p>We’ll create a new object on the window to avoid any naming conflicts, it will have a single function; setTitle(title) :</p><pre>window.jsInteropHead = {<br>    setTitle: (title) =&gt; document.title = title<br>};</pre><p>We then need to add this reference in the _Host.cshtml below the existing scripts:</p><pre>&lt;script src=&quot;_framework/blazor.webassembly.js&quot;&gt;&lt;/script&gt;<br>&lt;script&gt;navigator.serviceWorker.register(&#39;service-worker.js&#39;);&lt;/script&gt;<br>&lt;script src=&quot;_content/Blender.Web.Shared/Scripts/Head.js&quot;&gt;&lt;/script&gt;</pre><p>Note: I am always rendering on the server so I have deleted Index.html — You may need to add the script there as well if you plan on running a standalone client.</p><h3>Wrap it up in HeadViewModel</h3><p>In preparation for the Server-Side I’m actually going to introduce a very simple MVVM style ViewModel and corresponding EventArgs.</p><p>HeadViewModel:</p><pre>public class HeadViewModel<br>{<br>    public event EventHandler&lt;HeadViewModelChangedEventArgs&gt; HeadViewModelChanged;<br>    <br>    public string Title { get; set; }<br>    <br>    public void RaiseHeadViewModelChanged()<br>    {<br>        HeadViewModelChanged?.Invoke(this, new HeadViewModelChangedEventArgs(this));<br>    }<br>}</pre><p>HeadViewModelChangedEventArgs:</p><pre>public class HeadViewModelChangedEventArgs : EventArgs<br>{<br>    public HeadViewModelChangedEventArgs(HeadViewModel headViewModel)<br>    {<br>        HeadViewModel = headViewModel;<br>    }<br><br>    public HeadViewModel HeadViewModel { get; }<br>}</pre><p>We need to register this as a Singleton on the Client in <em>Blazor.Web.Client/Program.cs</em>:</p><pre>builder.Services.AddSingleton&lt;HeadViewModel&gt;();</pre><p>And register as Transient on the server in Blazor.Web.Server/Startup.cs :</p><pre>services.AddScoped&lt;HeadViewModel&gt;();</pre><h3>Create the Head Component</h3><p>Next create the Head compnent — this will make it easy for us to set the page title and any other elements in the &lt;head&gt; tags.</p><p>Create a new Head.razor component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*MZd5tOvfIKb3dapL-KfiNw.png" /><figcaption>Head.razor in file structure</figcaption></figure><pre>@using Microsoft.JSInterop<br>@inject IJSRuntime JsRuntime;<br>@inject HeadViewModel HeadViewModel<br><br>@code {<br>    [Parameter]<br>    public string Title { get; set; }<br><br>    protected override void OnInitialized()<br>    {<br>        HeadViewModel.Title = Title;<br>        HeadViewModel.RaiseHeadViewModelChanged();<br>    }<br><br>    protected override async Task OnAfterRenderAsync(bool firstRender)<br>    {<br>        await JsRuntime.InvokeVoidAsync(&quot;jsInteropHead.setTitle&quot;, HeadViewModel.Title);<br>    }<br>}</pre><p>As you can see, this component takes a single Parameter and does not render any UI.</p><p>It updates the Title property on the HeadViewModel and raises an event. This will be used shortly for setting the title on the Server.</p><p>In the OnAfterRenderAsync method we invoke our JavaScript function to set the title.</p><h3>Let’s use the Head Component</h3><p>Great, we’re almost done now.</p><p>In each of your pages you can now set the Title:</p><p>Blender.Web.Client/Pages/Counter.razor:</p><pre>@page &quot;/counter&quot;<br><br>&lt;Head Title=&quot;Counter&quot; /&gt;<br><em>@* ... *@</em></pre><p>Blender.Web.Client/Pages/FetchData.razor:</p><pre>@page &quot;/fetchdata&quot;<br>@inject WeatherForecastService WeatherForecastService<br><br>&lt;Head Title=&quot;Weather Forecast&quot; /&gt;<br><em>@* ... *@</em></pre><p>Blender.Web.Client/Pages/Index.razor:</p><pre>@page &quot;/&quot;<br><br>&lt;Head Title=&quot;Wecome to Blazor!!!&quot; /&gt;<br><br>&lt;h1&gt;Hello, world!&lt;/h1&gt;<br><em>@* ... *@</em></pre><p>Note: You might need to add the reference to your _imports.razor file:</p><pre>@using Blender.Web.Shared</pre><p>Now run the Blender.Web.Server application and you will see that the title is set:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yd6vUbGdVhTu33vAHeSw4A.png" /><figcaption>Showing the page titles set in the browser</figcaption></figure><h3>Finishing up the Server</h3><p>When inspecting the traffic we will see that the HTML from the server is not setting the title, this isn’t great for SEO.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6VjRv1dLl0KVmBSDZ5C9qw.png" /><figcaption>Dev tools showing the HTML markup returned by server.</figcaption></figure><p>Let’s update our App.razor — this is the entry point to the application. This allows us to optionally pass in an Action&lt;HeadViewModel and subscriber to the `HeadViewModelChanged` event.</p><pre>@inject HeadViewModel HeadViewModel<br><br>&lt;<strong>Router AppAssembly</strong>=&quot;@typeof(Program).Assembly&quot;&gt;<br>    &lt;<strong>Found </strong>Context=&quot;routeData&quot;&gt;<br>        &lt;<strong>RouteView RouteData</strong>=&quot;@routeData&quot; <strong>DefaultLayout</strong>=&quot;@typeof(MainLayout)&quot; /&gt;<br>    &lt;/<strong>Found</strong>&gt;<br>    &lt;<strong>NotFound</strong>&gt;<br>        &lt;<strong>LayoutView Layout</strong>=&quot;@typeof(MainLayout)&quot;&gt;<br>            &lt;p&gt;Sorry, there&#39;s nothing at this address.&lt;/p&gt;<br>        &lt;/<strong>LayoutView</strong>&gt;<br>    &lt;/<strong>NotFound</strong>&gt;<br>&lt;/<strong>Router</strong>&gt;<br><br>@code<br>{<br>    [Parameter]<br>    public Action&lt;HeadViewModel&gt; OnHeadViewModelUpdated { get; set; }<br><br>    protected override void OnInitialized()<br>    {<br>        if (OnHeadViewModelUpdated != null)<br>        {<br>            HeadViewModel.HeadViewModelChanged += (sender, args) =&gt;<br>            {<br>                OnHeadViewModelUpdated(HeadViewModel);<br>            };<br>        }<br>    }<br>}</pre><p>Next we need to update Blender.Web.Server/Pages/_Host.cshtml .</p><p>We are going to update the code at the top of the page to the following:</p><pre>@{<br>    Layout = null;<br>   <br>    var title = &quot;Blender&quot;;<br>    <br>    Action&lt;HeadViewModel&gt; onHeadViewModelUpdated = hvm =&gt;<br>    {<br>        title = hvm.Title;<br>    };<br><br>    var app = await Html.RenderComponentAsync&lt;App&gt;(RenderMode.<strong>Static</strong>, new {OnHeadViewModelUpdated = onHeadViewModelUpdated});<br>}</pre><p>We have declared a new title variable. We define our Action here and pass it as a property to the App.</p><p>Note that we are now rendering the App in code — this is because we need to render it before we can set the title — if not the title will not be updated.</p><p>In the Head tags we can now set our title:</p><pre>&lt;head&gt;<br>    &lt;meta charset=&quot;utf-8&quot;/&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;/&gt;<br>    &lt;title&gt;@title&lt;/title&gt;<br>    &lt;base href=&quot;~/&quot;/&gt;<br>    &lt;link rel=&quot;stylesheet&quot; href=&quot;css/bootstrap/bootstrap.min.css&quot;/&gt;<br>    &lt;link href=&quot;css/app.css&quot; rel=&quot;stylesheet&quot;/&gt;<br>    &lt;link href=&quot;manifest.json&quot; rel=&quot;manifest&quot; /&gt;<br>    &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;512x512&quot; href=&quot;icon-512.png&quot; /&gt;<br>&lt;/head&gt;</pre><p>And finally, update the html to use our @app variable.</p><pre>&lt;app&gt;<br>    <em>@* &lt;component type=&quot;typeof(App)&quot; render-mode=&quot;Static&quot;/&gt; *@<br>    </em>@app<br>&lt;/app&gt;</pre><p>That’s it — now we should be setting the title on the server for each of our pages!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wNLEFDdZlHWPYp_aiMNxCw.png" /><figcaption>Voila — We are now setting the title on the server!</figcaption></figure><p><a href="https://github.com/srpeirce/Blazor-SSR/pull/1/commits/6d7e9616c0f3307b5f0c706fe316742245effe61">You can see an example of this change on my experimental project here!</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7fb4ed6ec607" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Blazor — Detect if you are rendering on server or client]]></title>
            <link>https://medium.com/@srpeirce_67604/blazor-detect-if-you-are-rendering-on-server-or-client-998d37ac0980?source=rss-f5ebf64b75bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/998d37ac0980</guid>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[aspnetcore]]></category>
            <category><![CDATA[blazor]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <category><![CDATA[dotnet]]></category>
            <dc:creator><![CDATA[Steve Peirce]]></dc:creator>
            <pubDate>Sat, 30 May 2020 13:42:01 GMT</pubDate>
            <atom:updated>2020-05-30T13:42:01.801Z</atom:updated>
            <content:encoded><![CDATA[<h3>Blazor — How to pick and choose what you render on the server</h3><p>On my <a href="https://medium.com/@srpeirce_67604/server-side-render-blazor-client-side-app-wasm-efd3d9d12a6c">previous post</a> I talked about how to statically render your Blazor client-side application on the server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*VwN03P5EseWZGOgPub6nYQ.jpeg" /><figcaption>Selectively render components and pages in Blazor</figcaption></figure><h3>Don’t statically render all pages</h3><p>But why? In some cases it doesn’t make sense, for example call-backs from authentication.</p><p>This is pretty straight forward, open you _Host.cshtml and add some simple logic to choose whether to statically render or show you loading screen.</p><pre>&lt;app&gt;<br>    @if (HttpContext.Request.Path.StartsWithSegments(&quot;/authentication&quot;))<br>    {<br>        &lt;text&gt;Loading...&lt;/text&gt;<br>    }<br>    else<br>    {<br>        &lt;<strong>component type</strong>=&quot;typeof(App)&quot; <strong>render-mode</strong>=&quot;<strong>Static</strong>&quot;/&gt;<br>    }<br>&lt;/app&gt;</pre><h3>Don’t statically render a specific component</h3><p>Why not? In some cases where there is state on the browser, which will cause a flash of rendering on the UI.</p><p>A use case might be to not show your cookie policy banner for static rendering — it might be that we store the users acceptance in local browser storage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TXu8TDvdv8_swXcXG2t4tw.png" /><figcaption>Example cookie policy that we might not want to render statically.</figcaption></figure><h4>How can we achieve this?</h4><p>I suggest creating a new class to keep track of whether you are rendering on the client or server:</p><pre>public sealed class Rendering<br>{<br>    private readonly RenderOn _renderOn;<br>    <br>    public bool IsServerSide =&gt; _renderOn == RenderOn.<strong>Server</strong>;<br>    public bool IsClientSide =&gt; _renderOn == RenderOn.<strong>Client</strong>;<br><br>    private Rendering(RenderOn renderOn)<br>    {<br>        _renderOn = renderOn;<br>    }<br>    <br>    public static Rendering OnServer() =&gt; new Rendering(RenderOn.<strong>Server</strong>);<br>    public static Rendering OnClient() =&gt; new Rendering(RenderOn.<strong>Client</strong>);<br>    <br>    public enum RenderOn<br>    {<br>        <strong>Server </strong>= 0,<br>        <strong>Client </strong>= 1<br>    }<br>}</pre><p>Then we need to register this as a Singleton in the client project in Program.cs:</p><pre>builder.Services.AddSingleton(Rendering.OnClient());</pre><p>And likewise in the server project in Startup.cs</p><pre>services.AddSingleton(Rendering.OnServer());</pre><p>Next we just need to inject the Rendering in any of our component classes, e.g. in Index.razor:</p><pre>@page &quot;/&quot;<br>@inject Rendering Rendering<br><br>&lt;h1&gt;Hello, world!&lt;/h1&gt;<br><br>Welcome to your new app.<br><br>&lt;SurveyPrompt Title=&quot;How is Blazor working for you?&quot; /&gt;<br><br>@if (Rendering.IsServerSide)<br>{<br>    &lt;p&gt;Hello From Server.&lt;/p&gt;<br>}<br><br>@if (Rendering.IsClientSide)<br>{<br>    &lt;p&gt;Hello From Client.&lt;/p&gt;<br>}</pre><p>Vioala — You can now choose which components to render (or not) 🥳!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=998d37ac0980" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Server Side Render Blazor Client Side App (WASM)]]></title>
            <link>https://medium.com/@srpeirce_67604/server-side-render-blazor-client-side-app-wasm-efd3d9d12a6c?source=rss-f5ebf64b75bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/efd3d9d12a6c</guid>
            <category><![CDATA[dotnet-core]]></category>
            <category><![CDATA[webassembly]]></category>
            <category><![CDATA[blazor-wasm]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[blazor]]></category>
            <dc:creator><![CDATA[Steve Peirce]]></dc:creator>
            <pubDate>Sun, 24 May 2020 12:54:28 GMT</pubDate>
            <atom:updated>2021-06-13T19:25:59.735Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>NOTE: This article is now out of date. From Net6 Blazor supports PreRendering whilst preserving state. <br><a href="https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-preview-2/#preserve-prerendered-state-in-blazor-apps">ASP.NET Core updates in .NET 6 Preview 2 | ASP.NET Blog (microsoft.com)</a></blockquote><p>TL;DR; Example of Blazor Client app with SSR is here: <a href="https://github.com/srpeirce/Blazor-SSR">https://github.com/srpeirce/Blazor-SSR</a></p><h3>Background</h3><p>I spend most of my time developing in C# and .Net core. I’ve been keeping an eye on Blazor since the original experiments took place, but I’ve been waiting for the Client-Side (WebAssembly) version be released.</p><p>Blazor is the new framework in .Net Core for writing client side applications. I’m interested in the client model that uses WebAssembly to allow Single Page Applications written in C# to work in the browser (goodbye js ;P).</p><h3>Starting off</h3><p>I installed the latest version of <a href="https://dotnet.microsoft.com/download/dotnet-core">dotnet core</a>, in my case 3.1.300 — this ensures you have the latest dotnet new templates.</p><p>I created a new Blazor WASM project using the dotnet templates.</p><pre>dotnet new blazorwasm -ho -p -n Blender.Web`</pre><p>The flag -ho creates a Server project to host the client side app.</p><p>The flag -p configures the application to be a SPA.</p><p>This creates a solution file with 3 projects,</p><figure><img alt="Projects" src="https://cdn-images-1.medium.com/max/258/1*NF7q53lf7km1GHsx47xtqw.png" /></figure><h3>Running the app</h3><p>I ran the Blender.Web.Server to test the application. Everything is great, it runs…oh wait, except for those few seconds to load :(</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*vRGLPK56x3KEoxNw_WSuvg.png" /><figcaption>Loading Blazor WASM</figcaption></figure><p>Okay this is a Debug build, so I tried it passing in the Release flag and the loading was still noticeable.</p><p>I actually pushed the app to the cloud and loaded it from my Galaxy Note 8 — it took ~4 seconds to load the app.</p><p>This isn’t great — I’m not sure if this will be good for Production :-(</p><figure><img alt="Lighthouse report — Notice the rendering screenshots :(" src="https://cdn-images-1.medium.com/max/847/1*CEd1nncPxcJIJi0b3UqCHQ.png" /><figcaption>Notice the rendering screenshots from Lighthouse :( Note: This is running Debug configuration.</figcaption></figure><h3>Don’t give up</h3><p>Before calling it a day I thought I would try SSR. This is where the server renders the webpage on the server and sends the HTML to the browser. Then from that point the client side app takes over.</p><p>I couldn’t find any examples (perhaps my Google Foo was weak last night) so I felt my way through.</p><p>Here is what I ended up with….</p><h3>Adding Server Side Rendering (SSR) / PreRendering</h3><p>Create a new page:</p><pre>Create Blender.Web.Server/Pages/_Host.cshtml</pre><p>Copy the contents from the GitHub here: <a href="https://github.com/srpeirce/Blazor-SSR/blob/master/Blender.Web/Server/Pages/_Host.cshtml">_Host.cshml</a></p><p>The important parts are that we are choosing the ServerPrerendered render mode.</p><pre>&lt;app&gt;    <br>    &lt;component type=&quot;typeof(App)&quot; render-mode=&quot;Static&quot;/&gt;&lt;/app&gt;</pre><p>And we are choosing the client js file:</p><pre>&lt;script src=&quot;_framework/blazor.webassembly.js&quot;&gt;&lt;/script&gt;</pre><p>I deleted the Index.html as this isn’t needed anymore, this is because _Host.cshtml is now the entry point for out application. I do not intend to run/deploy the webassembly app standalone.</p><p>I then updated `Update Blender.Web.Server/Startup.cs` to map the fallback page to the new host page.</p><pre>app.UseEndpoints(endpoints=&gt;</pre><pre>{<br>    endpoints.MapRazorPages();<br>    endpoints.MapControllers();<br>    endpoints.MapFallbackToPage(&quot;/_Host&quot;);<br>});</pre><p>Note: We are not creating any SignalR circuits here, the server will just render the page but will not maintain a connection with the browser.</p><p>When we run the server we get Server Side rendering, whoohoo :D No loading page here, after the inital page load then we are running the client application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*wVt0uPVn3lNch-hr1S2cDA.png" /><figcaption>Checkout the rendering images. Note: This is running Debug configuration.</figcaption></figure><h3>All done….but wait what…!?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PP5wQTU30tOuFcgv_0nKFA.png" /><figcaption>Navigating to the page</figcaption></figure><p>Checking each page of the app, everything is great.</p><p>But wait, what happens when we refresh the Fetch Data page:</p><figure><img alt="Boom!" src="https://cdn-images-1.medium.com/max/1024/1*f_unHYsWAXNukTo2opJ-Tg.png" /><figcaption>Boom!</figcaption></figure><p>What has happened?</p><p>Okay we are missing a dependency of HttpClient on the server side. This is because the DependencyInjection configuration for HTTPClient has not been configured on the server application, it is seperate from the client app.</p><p>The fix, configure the DependencyInjection on the Server.</p><p>I actually extracted a <a href="https://github.com/srpeirce/Blazor-SSR/blob/master/Blender.Web/Shared/WeatherForecastService.cs">WeatherForecastService</a> for this experiment.</p><p>And updated the <a href="https://github.com/srpeirce/Blazor-SSR/blob/master/Blender.Web/Server/Startup.cs">Blender.Web.Server/Startup.cs</a>:</p><pre>public void ConfigureServices(IServiceCollection services)<br>{<br>    services.AddControllersWithViews();<br>    services.AddRazorPages();<br>    services.AddHttpClient&lt;WeatherForecastService&gt;(options =&gt; options.BaseAddress = new Uri(&quot;https://localhost:5001/&quot;));<br>}</pre><p>And updated the <a href="https://github.com/srpeirce/Blazor-SSR/blob/master/Blender.Web/Client/Program.cs">Blender.Web.Client/Program.cs:</a></p><pre>builder.Services.AddTransient(sp =&gt; new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });            builder.Services.AddTransient&lt;WeatherForecastService&gt;();</pre><p>And viola, everything now works!</p><p>The lesson:</p><p>When SSR we need to test each page from the Client and from the Server to make sure all of our dependencies are configured correctly.</p><h3>Oh Yerr, It’s a PWA</h3><p>We can install the App, whoohoo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*mVIQh1vPbu2qSGee883CpQ.png" /><figcaption>Install the PWA</figcaption></figure><p>Some further experimentation is needed, but it looks like speed might be okay…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=efd3d9d12a6c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>