Asp.net mvc 如何在mvc中获取httpget中的隐藏值

Asp.net mvc 如何在mvc中获取httpget中的隐藏值,asp.net-mvc,session,Asp.net Mvc,Session,我正在mvc中开发向导类型的应用程序,它将帮助人们预约,第一页它有就诊的原因,然后选择像wise一样的医生,最后预约。我有post和get方法来维护页面之间的数据。此应用程序不维护任何特定于用户的会话,而是基于医院id维护会话(医院链他们可以在任何医院预约,无需基于用户的身份验证,其基于医院id的会话维护) 我创建会话的方法是: public AppointmentRequest InitAppointmentRequest(string hospitalId) { var objApp

我正在mvc中开发向导类型的应用程序,它将帮助人们预约,第一页它有就诊的原因,然后选择像wise一样的医生,最后预约。我有post和get方法来维护页面之间的数据。此应用程序不维护任何特定于用户的会话,而是基于医院id维护会话(医院链他们可以在任何医院预约,无需基于用户的身份验证,其基于医院id的会话维护)

我创建会话的方法是:

public AppointmentRequest InitAppointmentRequest(string hospitalId)
{
    var objAppointment = new AppointmentRequest();
    _Appointment_WorkingState = "Appointment.WorkingState" + ":" + hospitalId;
    HttpContext.Current.Session[_Appointment_WorkingState] = objAppointment;
    return objAppointment;
}

public AppointmentRequest GetAppointmentSession(int hospitalId)
{
    _Appointment_WorkingState = "Appointment.WorkingState" + ":" + hospitalId;
    if (HttpContext.Current.Session[_Appointment_WorkingState] != null)
        return (AppointmentRequest)HttpContext.Current.Session[_Appointment_WorkingState];
    return null;
    //return RedirectToRouteResult("Index", "Appointment");
}
如果用户只打开一个url(),则可以正常工作;如果用户在同一浏览器中使用不同的hospital()复制同一url,则无法正常工作

如果我发布页面,我将从模型中传递hospitalid,并且工作正常。如果单击医院152,请在同一浏览器的下一个选项卡中导航到其他医院153并返回到152,然后单击“上一步”按钮其引发异常,因为我无法获取医院id是get method

 public ActionResult Index(string hospitalid)
 {
     var appointment = AppointmentRequest.InitAppointmentRequest(hospitalid);
    //some logics
    return view("index");
}

[HttpPost]
[Route("select-appointment-reason")]
public ActionResult AppointmentReason(AppointmentRequest model, FormCollection collection)
{
    var appointment = AppointmentRequest.GetAppointmentSession(model.HospitalId);
    //var appointment = AppointmentRequest.GetCurrent();
}

[HttpGet]
[Route("select-appointment-reason")]
public ActionResult AppointmentReason()
{
    // i need hospital id here to get the exact session.    
    var appointment = AppointmentRequest.GetAppointmentSession(hospitalid);
    return view(appointment);
}

在get方法中,我需要在调用
getappointmentsession
获取确切的会话值之前获取医院id。目前我没有任何隐藏字段,我知道,我只能在post方法表单集合中获取隐藏字段的值。我需要获取方法中的医院id,这是我的要求或解决此问题的最佳方法。

一个更简单、更干净的解决方案可能是在隐藏的容器中有一个单独的视图/表单,每个步骤都有下一步/上一步按钮,显示/隐藏相关步骤,最后一步有一个提交按钮(no
Session
)很好的建议,但我们在项目完成阶段,在最后一刻遇到了此类问题,时间不多了,请用现有方法找到替代解决方案。我看不到这一点,但实现单一视图/表单选项并不难()