title: Synchronously read file from wwwroot in Blazor Webassembly
body: <p>So I've been able to successfully read files asynchronously like <a href="https://stackoverflow.com/questions/58110347/reading-static-files-in-asp-net-blazor">so</a>.<br />
  I'm making a simple word game (hangman), and <strong>I'm reading the words from some text files in</strong> <code>wwwroot</code>.<br />
  On the new game screen, I have the user pick <strong>the length of the word</strong> to guess and <strong>the set of words</strong> they want to use (e.g. regular words, halloween themed words, christmas themed words etc.)</p>
  <p>The problem is when the user enters a number for the length of the word, I'm validating that there is a word of that length, and if there isn't then I set the number to the closest word length to what the user entered (e.g. if they entered 999 into the word length field and they were using the regular words list, it would be set to 18 because that's the longest word in the regular word list (telecommunications)). Basically, <strong>I need to read the file right when the user changes the word list</strong>, (at least with how I'm currently doing things) so that I can correctly validate if/when the user changes the word length field.</p>
  <p>I've tried doing something like:</p>
  <pre><code>public static string ReadFile(string localUrl) {
      return Http.GetStringAsync(localUrl).Result;
  }
  </code></pre>
  <p>Unfortunately Blazor doesn't like this and it throws a runtime exception when I try to do this.</p>
  <p>I'm currently binding my input fields to properties (like <code>&lt;input @bind=&quot;MyProperty&quot;&gt;</code>) because it seemed like an easy way to validate them, but properties can't be asynchronous. I had the idea that I could use <code>@onchange</code> in my word lists combobox to call an asynchronous method that updates the word list, but this feels a lot more messy and I feel like I'm probably going about this the wrong way.</p>
  <p>Should I stick with my solution of using <code>@onchange</code> to call an asynchronous method to update my list of words, or should I be doing things differently? Maybe load all my word lists at the beginning (it'd only be a few kb)? Or is there a better way to synchronously load files?</p>