How to retrieve the URL of the current Page in ASP.NET MVC 4 Controller ?

Published on February 18, 2013 by abundantcode

Filed under ASP.NET

Last modified February 18, 2013

Print this page

rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 5 (1 votes)

This article have been viewed 9995 times

If you want to retrieve the URL of the current Page in a ASP.NET MVC 4 Controller , you can get it by using the AbsoluteUri property defined in the Request.Url class.

How to retrieve the URL of the current Page in ASP.NET MVC 4 Controller ?

using System;
using System.Linq;

using System.Web;

using System.Web.Mvc;

namespace MvcApplication1.Controllers

{

public class EmployeeController : Controller

{

//

// GET: //AbundantCode Employee Action
public ActionResult Index()

{

string CurrentURL = Request.Url.AbsoluteUri;

return View(CurrentURL);

}

}

}
How to retrieve the URL of the current Page in ASP.NET MVC 4 Controller ?

How to retrieve the URL of the current Page in ASP.NET MVC 4 Controller ?

0saves
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

1 Comment

  1. Interesting .NET Links – February 19 , 2013 | TechBlog
    March 10, 2013 - 2:55 pm

Leave a Comment


x

You might be Interested in these Posts

How to return Json instead of XML in ASP.NET Web API ?

When you make a call to the ASP.NET Web API action method and notice this in Google Chrome browser ,...

How to Add Web API to existing ASP.NET Web Forms Project ?

In one of the previous posts , we saw how to add the WebAPI to the existing ASP.NET MVC project. Wel...

How to Add Web API to existing ASP.NET MVC Project ?

There are times when you might want to add Web API project to one of your existing ASP.NET MVC proje...