1
參數

我重定向我的動作到另一個網址woth可選參數和變量傳遞給控制器​​MVC URL RedirectToAction 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

你試試這個? (我不知道它是否工作)

RedirectToAction("action", new { a = a, c = c, s = s,ds = ds}); 

髒的方法是:

Redirect("/area/home/action?a=" + a + "&b=" + b + "&c=" + c + "&ds=" + ds); 

其實我用的是第二個經常,因爲它更清晰的看到所有的參數和值。唯一的缺點是,如果URL中有任何錯誤,則不會有任何警告。