2011-01-27 3 views
0

샌드위치를 ​​편집하기위한 MVC보기가 있습니다. 샌드위치 이름, 가격 등.이 양식에는 고유 한 제출 단추가 있습니다. 양식을 제출하면 POST 편집 조치가 호출되고 샌드위치가 갱신되며보기가 다시로드됩니다.ASP.NET MVC보기의 여러 양식 및 라우팅 문제

그런 다음 동일한보기에서 샌드위치 편집 양식 아래에 재료 옆에 추가 버튼이있는 드롭 다운 목록이 있습니다. 다른 성분에 첨가물 첨가물 모양 포스트를 어떻게 만드십시오, 그러나 편집 전망을 다시 적재합니까?

RedirectToAction ("편집")은 많은 정크를 URL에 넣습니다. 여기

작동 내가 시도 하나의 방법이지만, URL에 쓰레기를두고 : 여기
[AcceptVerbs(HttpVerbs.Post)] 
    public ActionResult LoginRemoveAssociation(FormCollection values) 
    { 
     int webUserKey = Int32.Parse(values["WebUserKey"]); 
     int associationKey = Int32.Parse(values["AssociationKey"]); 
     db.DeleteWebUserAssociation(webUserKey, associationKey); 
     return RedirectToAction("LoginEdit", new LoginEditViewModel(webUserKey, true)); 
    } 

가 RedirectToAction 후 URL에서 정크 :

https://localhost/mvc/Admin/Login/382?WebUser=Web.Data.Entities.WebUser&Associations=System.Data.Objects.ObjectQuery`1[Web.Data.Entities.Association]&WebUserAssociations=System.Data.Objects.DataClasses.EntityCollection`1[Web.Data.Entities.WebUserAssociation]&ManagementCompanies=System.Collections.Generic.List`1[Web.Data.Entities.ManagementCompany]&ManagementCompanyList=System.Web.Mvc.SelectList&AccessLevels=System.Collections.Generic.List`1[Web.Data.Entities.AccessLevel]&AccessLevelList=System.Web.Mvc.SelectList&PostMessage=Changes%20saved. 
+0

"RedirectToAction ("편집 ")은 많은 정크를 URL에 넣습니다."정크 "의 예를 게시 할 수 있습니까? – Chandu

+0

포스트가 정크로 편집 됨 :) – Blackcoil

답변

0

이유 왜 귀하의 URL에 "정크"를 가져 오는 것은 LoginEditViewModel을 편집 작업에 전달하기 때문입니다. .Net은 개체를 매개 변수로 전달할 수 있도록 개체를 이름으로 변환하려고 사용하고 있습니다. 그래서 당신이 보는 Web.Data.Entities .......

편집 컨트롤러는 어떻게 생겼을까요?

그 무언가가 같은 경우

public ActionResult Edit(int id) 

그런 조치로 리디렉션해야 뭔가 같은 :

return RedirectToAction("Edit", new { id = 1 }); 

보다는 뷰 모델을 전달합니다.

+0

그건 정확히 그랬습니다! 감사! – Blackcoil