MVC3 Getting the URI in a controller

If there is a need to get the URI that the was used to reach the controller then the Request holds that information and it can be retrieved to a URI object

public ActionResult MyAction()
    var uri = Request.Url;
    var port = uri.Port;
    var absoluteUri = uri.AbsoluteUri
    //... do things here
    return View();    

One thought on “MVC3 Getting the URI in a controller

  1. Pingback: MVC3 check what url was called (regardless of server/interface) « Jontas

Comments are closed.