title: Redirect from Blazor Component(.razor) to Razor Page(.cshtml) [ServerSide]
body: <p>Here's my use case. I have a singleton object that is holding global site state. I have a button on my website that when clicked fires an event on the global site state object. I have a Blazor component(razor) that is listening for this event. It responds to the event by doing this</p>
  <pre class="lang-cs prettyprint-override"><code>var path = &quot;siteupdate&quot;.AddInitialQueryStringArg(&quot;returnUrl&quot;, _navManager.Uri);
  _navManager.NavigateTo(path,true);
  </code></pre>
  <p>The idea is that all online users are redirected to a Razor page(.cshtml) that has a message saying &quot;The Website is being updated, come back later&quot;. This is a requirement to provide a decent user experience for when the server goes down temporarily for an update and loses connection to the SignalR hub.</p>
  <p>Following the execution it appears as if the navigator tries to navigate to the <code>siteupdate</code> page but it ends up getting rejected and resets back to whatever component I was on when I make the call. Similar to when you try to update the url in the browser manually and the navmanager resets it. Putting breakpoints in my Razor Page I can tell that the <code>OnGet</code> method gets called most of the time, but it seems like it's response is not being acknowledge or something? I've tried the following :</p>
  <p>Attempted to set window location via javascript</p>
  <pre class="lang-cs prettyprint-override"><code>
  var path = &quot;/update&quot;.AddInitialQueryStringArg(&quot;returnUrl&quot;, _navManager.Uri);
  JSRuntime.InvokeVoidAsync(&quot;BlazorHelpers.RedirectTo&quot;, path);
  </code></pre>
  <p>Attempted to not use force reload, this results in a 404</p>
  <pre class="lang-cs prettyprint-override"><code>var path = &quot;/siteupdate&quot;.AddInitialQueryStringArg(&quot;returnUrl&quot;, _navManager.Uri);
  _navManager.NavigateTo(path);
  </code></pre>
  <p>For reference I have the Razor page under
  Pages/SiteUpdate/UpdateLandingPage.cshtml
  I tried placing it just under the Pages folder, but like I said earlier the <code>OnGet</code> method is getting called so the router seems to be finding it, but it seems like the framework is overwriting the URL somehow.</p>
  <p>Thanks</p>