Why is there a difference between Response.Redirect and the new RedirectResult ()?

When I redirect in this way

 protected override void OnActionExecuting(ActionExecutingContext filterContext)
 {
      filterContext.Result = new RedirectResult("https://mydom.com");
 }

therefore the browser is redirected to http://mydom.com/httpS://mydom.com

but if i redirect this path

 protected override void OnActionExecuting(ActionExecutingContext filterContext)
 {
      var res = filterContext.HttpContext.Response;
      filterContext.Result = res.Redirect("https://mydom.com");
 }

so that the browser redirects https://mydom.com correctly

Why is there a difference?

+5
source share
1 answer

First of all, it RedirectResultis a class, while it HttpResponse.Redirectis a method. Although the former redirects the user to the specified URI, the latter redirects you to the specified URL. To see the differences between a URL and a URI, see here .

Hope that helps

+2

All Articles