VIRTUAL DAN

VIRTUAL DAN

Notes from my travels around the internet

VIRTUAL DAN
  • My Pacific Northwest Solar
  • About
Monthly Archives: October 2020

Blazor and WordPress – The Story Continues

Recently I got a comment on my first Blazor and WordPress blog post that my demo wasn’t working. I hadn’t looked at it in months, but sure enough my weather forecast component wasn’t rendering. Blazor was working, but it was defaulting to ‘route not found’ condition.

I have learned a bit more since my original experiment, so I dug back into my demo and made some improvements.

In my first version, I used the router, and set my @page directive to match the url of the blog post.

For some reason the router was no longer recognizing that route. I assume some wordpress upgrade messed with the url rewriter, but I didn’t look into that closely – I decided that was the wrong approach. Instead, I just updated the router (my app.razor file) to rely on the notfound condition:

Now my app has no routes defined, and I rely on my defaultlayout.razor page to always render. Note that I can likely get rid of the <Found condition in the router – I didnt only because it was working and I didn’t want to mess with it anymore.

So my DefaultLayout.Razor file is pretty simple:

All it essentially does is render my weather forecast component. I think this is a much better pattern to use when embedding Blazor in WordPress. If you do need to deal with routing, my recommendation would be to either sniff the url in your blazor app and decide what to do, or just control the state of your components by setting variables that cause components to either show or hide.

A couple other thoughts:

  • You may have to add mime types to your WordPress server if your app doesn’t work or you get console errors. Take a look at the web.config that gets generated when you publish, and you will see the ones you need.  If you manage the wordpress hosting server you can add them in on your admin panel.  If not, there are some wordpress plugins that allow you to manage mimetypes.
  • I am beginning to wonder if embedding blazor in wordpress is the right architecture.  The other option is build a blazor app that calls the wordpress API – and just have it pull all the wordpress content into your standalone blazor app.  That way you can still maintain the content in wordpress, but you have the full flexibility of blazor routing. If you don’t change your themes a lot, and you don’t require a lot of plugins, this approach might be better.  Just a thought.  SEO would be an issue in this approach though, since search engines don’t appear to index Blazor apps.

For reference, below is the working example of the Blazor rendered weather forecast:

Loading…

I am surprised there is not more chatter on the internet about integrating WordPress and Blazor – its a pretty interesting solution to quickly adding components to a WordPress site. If you follow the instructions from my previous post, along with the things I learned above, you can easily get it set up.

Buy Now
Professional WordPress: Design and Development (Kindle Edition)
Read More
Buy Now
Building Web Apps with WordPress: WordPress as an Application Fra…
Read More
Buy Now
WordPress 5 Complete: Build beautiful and feature-rich websites f…
Read More
October 29, 2020 Dan 3 Comments

Adventures in Bonds

For years I have held several bond funds, from corporate to high yield and international bonds, and I have been fairly satisfied with that low risk, low return portion of the portfolio.

As mentioned in a previous post, I am re-evaluating my allocation to bonds and bond funds, but I have also been experimenting with buying bonds directly rather than funds. It has been an interesting experience, and I thought it would be worth recapping a few points below.

  1. High Yield Bonds. For years I have owned the Vanguard High Yield bond fund, which is probably the lowest cost high yield fund out there. Earlier this year, I reduced my allocation in high yield bonds, primarily because they tend to correlate more to the stock market than the bond market. Since my objective to buying bonds is to diversify from the stock market, that kind of defeats the purpose. However, as rates have fallen further and further, I decided to switch some of my corporate low-yield bond allocation to high yield, and take control of buying the bonds myself. The hope is I can get a little higher yield than just regular bonds, thus keeping the correlation with the stock market lower. High yield bond funds typically have a huge allocation to energy stocks, which in this environment I also want to stay away from. So I have been building a portfolio of reasonable quality short term maturities that are technically high yield, but I expect will behave more like bonds. I have bought bonds issued by companies such as T-Mobile, Netflix, Best Buy, and Lennar Corp which I feel pretty comfortable owning. Of course, I sacrifice yield for this, but I do feel better owning bonds in companies I understand.
  2. TIPS. I can’t do a post on bonds without mentioning TIPS – Treasury Inflation protected securities. TIPS are issued by the Federal government and the interest rate is pegged to the inflation rate. These rates naturally are very low.. but then what isn’t? My recommendation for anybody considering TIPs is to make sure and buy I-Bonds from treasurydirect.gov first. The government limits the purchase of I-Bonds to $10,000 per Social security number. The current composite rate for I-Bonds is 1.06% which in most worlds is terrible. However, you can withdraw them penalty free after 5 years (so effectively a 5 year maturity), plus you get inflation protection. In past years there has been a fixed component to the rate, so it was even a better deal, but the current rate is still above a 5 year CD rate, and if inflation increases, you will do even better. And you know the Fed is trying everything it can to increase inflation.
  3. Foreign Bonds. I have foreign bond funds, and I was considering starting to allocate to owning individual foreign bonds. So I started by looking at the holdings in the Vanguard Emerging Market Bond ETF. This fund has a yield of 3.89%, which is nice in this environment. However, the average maturity is pretty high at 13+ years, which is way longer than I would typically buy a bond for (who knows what he world will look like in 13 years?). It then occurred to me that I have no strong feeling about which countries are over or under priced. I also looked at the market value they had listed for some of their bonds, and looked at the price I could buy the bond for, and in most cases their listed price was about 1% cheaper than I can buy the bond for. I am pretty leery about bond spreads, especially when rates are so low – a 1% spread is in many cases one years worth of interest. So for now, I think I will continue to buy foreign bonds thru funds, as I don’t think I can outperform the experts by 1%.

My foray into holding individual bonds has been interesting, and it makes me feel better when I understand what I own. That is probably the biggest benefit to buying bonds outright. Even if I was a bond wizard I don’t think I can win big holding bonds vs funds. The biggest benefit is probably education and learning about how the bond market works.

Buy Now
How to invest in bonds: a simple guide to investing in bonds…
Read More
Buy Now
How I Trade and Invest in Stocks and Bonds (Paperback)
Read More
Buy Now
How I Trade and Invest In Stocks and Bonds (Illustrated): Be…
Read More
October 15, 2020 Dan Leave a comment

Archives

  • August 2021 (1)
  • May 2021 (1)
  • April 2021 (1)
  • March 2021 (1)
  • February 2021 (1)
  • January 2021 (1)
  • December 2020 (2)
  • November 2020 (2)
  • October 2020 (2)
  • September 2020 (2)
  • August 2020 (2)
  • July 2020 (2)
  • June 2020 (2)
  • May 2020 (2)
  • April 2020 (2)
  • March 2020 (2)
  • February 2020 (2)
  • January 2020 (3)
  • December 2019 (2)
  • November 2019 (2)
  • October 2019 (2)
  • September 2019 (1)
  • August 2019 (2)
  • July 2019 (2)
  • June 2019 (1)
  • May 2019 (3)
  • April 2019 (2)
  • March 2019 (2)
  • February 2019 (2)
  • January 2019 (3)
  • December 2018 (2)
  • November 2018 (2)
  • October 2018 (2)
  • September 2018 (2)
  • August 2018 (2)
  • July 2018 (2)
  • June 2018 (2)
  • May 2018 (2)
  • April 2018 (2)
  • March 2018 (2)
  • February 2018 (1)
  • January 2018 (3)
  • December 2017 (2)
  • November 2017 (2)
  • October 2017 (2)
  • September 2017 (2)
  • August 2017 (2)
  • July 2017 (2)
  • June 2017 (3)
  • May 2017 (2)
  • April 2017 (1)
  • March 2017 (3)
  • February 2017 (3)
  • January 2017 (2)
  • December 2016 (2)
  • November 2016 (3)
  • October 2016 (2)
  • September 2016 (2)
  • August 2016 (2)
  • July 2016 (2)
  • June 2016 (2)
  • May 2016 (2)
  • April 2016 (2)
  • March 2016 (2)
  • February 2016 (3)
  • January 2016 (4)
  • December 2015 (2)
  • November 2015 (2)
  • October 2015 (3)
  • September 2015 (3)
  • August 2015 (2)
  • July 2015 (4)
  • June 2015 (2)
  • May 2015 (4)
  • April 2015 (3)
  • March 2015 (4)
  • February 2015 (4)
  • January 2015 (4)
  • December 2014 (5)
  • November 2014 (3)
  • October 2014 (5)
  • September 2014 (3)
  • August 2014 (5)
  • July 2014 (4)
  • June 2014 (4)
  • May 2014 (3)
  • April 2014 (3)
  • March 2014 (5)
  • February 2014 (2)
  • January 2014 (5)
  • December 2013 (4)
  • November 2013 (6)
  • October 2013 (3)
  • September 2013 (3)
  • August 2013 (4)
  • July 2013 (3)
  • June 2013 (3)
  • May 2013 (5)
  • April 2013 (2)
  • March 2013 (6)
  • February 2013 (6)
  • January 2013 (5)
  • December 2012 (5)
  • November 2012 (4)
  • October 2012 (3)
  • September 2012 (4)
  • August 2012 (3)
  • July 2012 (3)
  • June 2012 (2)
  • May 2012 (3)
  • March 2012 (3)
  • February 2012 (2)
  • January 2012 (1)
  • December 2011 (3)
  • November 2011 (3)
  • October 2011 (2)
  • September 2011 (2)
  • August 2011 (3)
  • July 2011 (4)
  • June 2011 (4)
  • May 2011 (3)
  • April 2011 (6)
  • March 2011 (8)
WEBSITE DISCLAIMER: The operator of this site (Vertical Financial Systems, Inc) are not registered investment advisers, broker/dealers, or research analysts/organizations. The content on this website is issued solely for information purposes and should not to be construed as an offer to buy, sell, or trade in any way, any security mentioned herein. All information presented on this website is believed to be reliable and written in good faith, but no representation or warranty, expressed or implied is made as to their accuracy, completeness or correctness. You are responsible for doing your own research before investing in any securities mentioned herein. Readers are urged to consult with their own independent financial advisors with respect to any investment. Neither Vertical Financial Systems, Inc, nor its officers or employees accept any liability whatsoever for any direct or consequential loss arising from any use of information on this website.
Full Disclosure: As an Amazon Associate I earn from qualifying purchases
Powered by WordPress | theme SG Simple