我有以下動作的方法:所有模型值都顯示在URL中,這是正常的嗎?
public ActionResult ViewEmployeeDetails(Employee emp)
{
return View(viewName: "EmployeeView", model: emp);
}
此方法是顯示員工詳細信息。 Employee類有幾十個屬性。我的問題是,所有的屬性值顯示在這樣的網址:
http://mymvcapp.com/Employees/ViewEmployeeDetails?DocID=1&EditDate=07%2F25%2F2014%2011%3A00%3A43&IdSerial=AZE&IdNo=09270599&LastName=Abdullayev&FirstName=Mikayil&Patronymic=Cavanshir&Address=Mir%20C%C9%99lal%20k%C3%BC%C3%A7%C9%99si%2059%20K%2C%20451&Address2=Da%C4%9Fl%C4%B1q%20k%C3%BC%C3%A7%C9%99si%2022A&Gender=Male&NationalityID=1&JobDescription=A%C4%B0ST%20Qrup%20MMC&SocialStatus=Servant&SocialCategory=Disabled1&Phone=994503335553&Email=mikayil.abdullayev%40gmail.com&AddressedOfficerID=1&ReceptionMethod=Letter&ApplicationType=Application&SheetCount=14&ReceivedDate=07%2F29%2F2014%2000%3A00%3A00&Subject=DegreeOfDisablity&OrganizationID=63&AttachedDocNumber=12121212&AttachedDocDate=07%2F14%2F2014%2000%3A00%3A00&Author=Mikola&IsUnderControl=True&IsUnderControlInt=1&PreferredReplyMethod=Written&Status=None&Attachment=System.Byte%5B%5D
是否確定要離開它像這樣還是我有這種行爲的結束了一個可怕的做法?
你不能只是傳遞了'ID'的員工'ViewEmployeeDetails'方法和負荷數據在ViewEmployeeDetails'方法中設置'ID'並設置'Employee'對象? – Saranga
嗯,我認爲我返回視圖後得到了很長的URL。事實證明,事情發生之前,我的意思是當我將Employee對象接收到操作方法中時,對嗎? –
是的,在你當前的方法中,你傳遞了所有的細節,因爲你的方法中有'(Employee emp)'(期望Employee對象)。您只需傳遞「員工」的相關ID即可。 – Saranga