首先對不起我的英語不好,我是法國人。我會盡力讓我明白:)如何不通過URL傳遞參數?
我想從視圖傳遞參數到控制器沒有使用該網址。
參數是一個用戶標識符,我不希望有人在url中手動更改它。
我的視圖代碼:
<% foreach (var item in ViewData["ClientsList"] as List<SalesCoverseal_V2.Models.Customer>)
{ %>
<tr>
<td>
<%: Html.ActionLink("Editer", "ClientEdit", new { id=item.PersonId }) %>
<%: Html.ActionLink("Faire une offre", "Index", new { controller
= "Offer", id=item.PersonId }) %>
在控制器:
public ActionResult Index(string id)
{
if (currentLoginUser != null)
{
CurrentCustomer = WebService.GetClientInfos(id);
SessionManager.CurrentCustomer = CurrentCustomer;
OfferViewModel viewmodel = new OfferViewModel();
return View(viewmodel);
}
My url :
> http://localhost:50905/Offer/Index/WS00000401
But I don't want this url, I want
> http://localhost:50905/Offer/
你能幫助我嗎?謝謝
我想過,但是當我使用FormMethod.Post,我的參數不在[HttpPost]在我的控制器通過。 – Akawan 2010-10-07 08:29:42
當您使用FormMethod.Post時,表單集合中的所有表單值都將在請求中傳遞(而不是URL作爲查詢字符串)。然後在服務器模型綁定中將這些值映射到您的操作參數。 – 2010-10-07 08:56:11