获取完整的请求URL - ASP.NET MVC
问题描述:
我有服务器请求:。获取完整的请求URL - ASP.NET MVC
而且我Action
:
public ActionResult Index()
{
stringUrl = ;
return RedirectToAction("Index","Home");
}
我想要得到的字符串:“asdhkjashdaskjdhqwehw”在Action
指数。
答
我发现它。 使用:“HttpContext.Request.Url.ToString()
”
答
您可以发送更多的参数重定向包含您的数据:
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");
}
我很抱歉,我的问题不清楚。你可以检查它。 –
您也可以通过使用您的网址的实际参数以类似的方式获取数据 –