如何在ASP.NET MVC 2的QueryString返回查看? [英] How to return View with QueryString in ASP.NET MVC 2?

查看:139
本文介绍了如何在ASP.NET MVC 2的QueryString返回查看?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在开发ASP.NET MVC 2的网站在某些时候,我得到一个ActionResult的控制器中,我明显地调用方法

I'm developing a web site in ASP.NET MVC 2. At some point, I get to a ActionResult in a controller and I obviously call method

return View();  

有什么办法,我可以通过查询字符串到我的观点或附加URL参数的?

Is there any way, that I could pass QueryString into my view or attach parameters to the URL?

推荐答案

您可以尝试

public ActionResult Index()
{
    RouteValueDictionary rvd = new RouteValueDictionary();
    rvd.Add("ParamID", "123");
    return RedirectToAction("Index", "ControllerName",rvd);
}

不要忘了包括此

using System.Web.Routing;

或者干脆你可以试试这个

or simply you can try this

return RedirectToAction("Index?ParamID=1234");

这篇关于如何在ASP.NET MVC 2的QueryString返回查看?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆