title: Getting the local URL in mvc/ Controller not recognising local url
body: <p>I a trying to test the following code. This is a summarised code.</p>
  
  <pre><code>string url = filterContext.HttpContext.Request.Url.ToString();
  if (Url.IsLocalUrl(url))
          {
              return Redirect(url);
          }
          else
          {
              return RedirectToAction("Index", "Home");
          }
  </code></pre>
  
  <p>In this code the url is obtained from context but in my original code it is passed to the controller action as string from a Authorize filter and looks like <code>http://localhost:53249/Products</code> in Debug.Write. However the <code>IF</code> is not satisfied that the url is local URL can someone explain what I am doing wrong.</p>