title: How do I pass returnUrl to Login page in Blazor Server application?
body: <p>I have a simple Blazor server application, with Identity using Individual Authentication.  I created the app from the VS 2019 standard <code>dotnet new</code> template.</p>
  
  <p>In some parts of the app I would like to direct the user to the login page, while passing along a <code>returnUrl</code> parameter.  I've tried the following variations of code to pass this parameter (<strong>counter</strong> is the page I want to return to):</p>
  
  <pre><code>NavigationManager.NavigateTo("Identity/Account/Login?returnUrl=counter", forceLoad: true);
  </code></pre>
  
  <pre><code>NavigationManager.NavigateTo("Identity/Account/Login?returnUrl='/counter'", forceLoad: true);
  </code></pre>
  
  <pre><code>NavigationManager.NavigateTo("Identity/Account/Login?returnUrl='./counter'", forceLoad: true);
  </code></pre>
  
  <pre><code>NavigationManager.NavigateTo("Identity/Account/Login?returnUrl='~/counter'", forceLoad: true);
  </code></pre>
  
  <p>However, with all of these, I get an error message that the "URI is not local".  Error message is:</p>
  
  <blockquote>
    <p>"InvalidOperationException: The supplied URL is not local. A URL with
    an absolute path is considered local if it does not have a
    host/authority part. URLs using virtual paths ('~/') are also local."</p>
  </blockquote>
  
  <p>Can anyone suggest the proper formatting of the returnUrl parameter in this situation?  For further background, I am following suggestions from @iambacon (thanks to Colin!), in his <a href="https://www.iambacon.co.uk/blog/blazor-authentication-and-authorisation-redirect-to-login" rel="noreferrer">blog post</a> about redirecting to the login page for Blazor apps.  It's a great article and accomplishes part of what I want: redirect to login when the user is not authenticated.  I would just like to add the extra feature of returning back to that URL after the auth is complete.</p>