zoukankan      html  css  js  c++  java
  • How to return View with QueryString in ASP.NET MVC 2?

    How to return View with QueryString in ASP.NET MVC 2?

    回答1

    A view is supposed to manipulate the model which is passed by the controller. The query string parameters are already present when the request was made to the corresponding action. So to pass a view model:

    var model = new MyViewModel
    {
        SomeParam = "Some value"
    }
    return View(model);
    

    And now in your view you could use this model.

    If on the other hand you don't want to return a view but redirect to some other controller action you could:

    return RedirectToAction("SomeOtherActionName", new { ParamName = "ParamValue" });
    

    回答2

    You can try

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

    Don't forget to include this

    using System.Web.Routing;
    

    or simply you can try this

    return RedirectToAction("Index?ParamID=1234");
    
  • 相关阅读:
    vue.api
    v-resource
    vue.js路由
    computed watch methods
    vue.js生命周期
    flex布局
    字符截取 slice substr substring
    原生Ajax书写
    jq动画
    css 3动画
  • 原文地址:https://www.cnblogs.com/chucklu/p/15509615.html
Copyright © 2011-2022 走看看