我将我的Action重定向到另一个带有可选参数的url并将变量传递给控制器
RedirectToAction("action", new { a, c, s,ds});
but my urls loosk like this
http://localhost:8080/contoller/action?a=1&c=2&s=3&ds=4
but when i directly call teh action the url looks like this
http://localhost:8080/contoller/action/1/2/3/4
how can i get the same url with redirect ..any suggestion
答案 0 :(得分:0)
RedirectToAction("action", new { a = a, c = c, s = s,ds = ds});
一种肮脏的方法是:
Redirect("/area/home/action?a=" + a + "&b=" + b + "&c=" + c + "&ds=" + ds);
事实上我经常使用第二个,因为看到所有参数和值更清楚。唯一不足的是,如果网址中有任何错误,则没有警告。