获取完整请求URL - ASP.NET MVC

时间:2017-02-20 04:28:02

标签: asp.net asp.net-mvc asp.net-mvc-4 asp.net-mvc-3

我向服务器请求如:"http://localhost/Login/Index?asdhkjashdaskjdhqwehw"

我的Action

public ActionResult Index()
{
     stringUrl = ;
     return RedirectToAction("Index","Home");
}

我想在Action 索引中获取字符串:“asdhkjashdaskjdhqwehw”

2 个答案:

答案 0 :(得分:0)

您可以通过发送包含数据的其他参数来重定向:

public ActionResult Index()
{
     stringUrl = ;
     return RedirectToAction("Index","Home", new {data = "asdhkjashdaskjdhqwehw" });
}

在您的主页索引操作中,您可以通过操作中的参数获取数据:

public ActionResult Index(string data) // data contains the data passed
{
     return RedirectToAction("Your URL");
}

答案 1 :(得分:0)

我找到了。 使用:" HttpContext.Request.Url.ToString()"

相关问题