0

We have a job application that uses a two step process. I need to tweak this slightly. The easiest way I can see doing this is removing the application creation stage from step one, and just passing it to step two which is a separate view.

Page 1 - Step 1

public ActionResult Apply(JobApplicant jobapp, string HiddenJobId)
        {
            jobapp.JobID = Convert.ToInt32(HiddenJobId);
            //JobsHelper.CreateJobApplicant(jobapp);

            return View("ApplyResume", jobapp); 
        }

The above code used to CreateJopApplication(). I commented this out and am now passing this to the next step/page.

However once on this new page I then have an [HttpPost] that takes that jobapp but at this point it is all null.

The jobapp(JobApplication) is about 140 columns, I'd hate to have to create a hidden text field for all of that. Is there an easier way to pass a model across two pages?

Step 2 - Page 2

[HttpPost]
        public ActionResult Upload(HttpPostedFileBase file, string applicantId, string coverLetter, JobApplicant jobapp)
        {
            // jobapp is null during this entire step, passed in null its as if the page before never had it.
            JobsHelper.CreateJobApplicant(jobapp);
            .......
James Wilson
  • 5,074
  • 16
  • 63
  • 122
  • 1
    look [here](http://stackoverflow.com/questions/14138872/how-to-use-sessions-in-an-asp-net-mvc-4-application) – Jonesopolis Oct 23 '14 at 17:03
  • Is there a particular reason why you *need* two steps? Seems silly to me to have a user fill out 140 fields and then take them to another step just to upload something. Just add the upload to the same initial step. – Chris Pratt Oct 23 '14 at 17:29
  • @ChrisPratt Other than that is how it was originally designed nope. If working from scratch I would have designed it all on the same page. – James Wilson Oct 23 '14 at 17:35

1 Answers1

1

You may be able to use TempData. It is like a session state but it's removed once it gets used. It is good for one round trip.

With a stateless framework like MVC, you can:

  • Persist inside the form using hidden fields
  • Persist in database
  • Persist in session state or temporary state
beautifulcoder
  • 10,832
  • 3
  • 19
  • 29