2012-10-15 53 views
0

我將一個對象傳遞給一個操作方法,並且該操作方法顯示該視圖,但它擁有查詢字符串中的所有協議,並且我不想要這樣json字符串不能通過url)。我怎樣才能傳入模型對象,而不是在查詢字符串中?另外,當您擁有強大的類型視圖時,模型商店的對象值在哪裏?謝謝你的幫助。將對象傳遞給mvc中的操作方法在查詢字符串中放置屬性

 //This works fine when I am calling /controller/uploader 
     public ActionResult Uploader(Model model) 
     { 
     //logic 
     return View(model); 
     } 

     //But when I am on another method and want to call uploader it does pass the object but puts //all the data in a querystring 
     public void DoSomething(string val, string anotherval){ 
     Model model = new Model(); 
     Uploader(model);//This passes the object but when uploader page shows it has all the //model object properties in querystring and I do not want that. 

return RedirectToAction("Uploader",model);//or this does the same thing 
    } 

回答

1

嘗試使用POST方法的HTML形式:

<form action="/uploader" method="POST"> 
    <!-- maybe some input elements? --> 
    <input type="submit" /> 
</form> 

這將轉移請求體中編碼的數據作爲表格,並保持數據輸出的查詢字符串的。

相關問題