0

Url passed in is: "/Reporting/Dashboard"

Why is the Url.get returning null?

public ActionResult RedirectToLocal(string returnUrl)
{
    if (Url.IsLocalUrl(returnUrl))
    {
        return Redirect(returnUrl);
    }
    else
    {
        return RedirectToAction("Index", "Dashboard", new { area = "Reporting" });
    }
}

enter image description here

crichavin
  • 4,672
  • 10
  • 50
  • 95

1 Answers1

0

Your problem here is not with returnUrl, but with Controller.Url property, which is null, so you can't access IsLocalUrl() method of null object.

Without more information it is hard to undestand where is the problem, but this could something with your refferences.

Here is related issue: Why is Controller.Url null when I unit test my action?

I would suggest to create fresh new simple project with this implementation and see if problem still persits.

mr_city
  • 1
  • 2