title: how to pass data from view to controller or pass data between controllers in aspnet Core MVC
body: <p>Hello I'll go straight to my problem 
  I have RiddleController have 2 IActionResult like this</p>
  
  <pre><code>    [HttpGet]
      public IActionResult Edit(int id){
          ViewBag.ChapterOpt = _context.Chapters.OrderBy(c =&gt; c.ID).ToList();
          string referrer = Request.Headers["Referer"].ToString();
          ViewBag.referrer = referrer;
          var riddle =_context.Riddles.Find(id);
          return View(riddle);
      }
  
      [HttpPost]
      public IActionResult Edit(Riddle riddle){
          if(ModelState.IsValid)
          {
              // how can i get the referrer from Edit(GET) upthere to 
              // this referrer
              // string referrer = Request.Headers["Referer"].ToString();
  
              var qt = _context.Riddles.Find(riddle.ID);
              qt.ChapterID  = riddle.ChapterID;                
              qt.Content  = riddle.Content;
              qt.Suggestion  = riddle.Suggestion;
              _context.SaveChanges();
              return RedirectToAction("Index","Riddle");
          }
          else
          {
              return View();
          }
      }
  </code></pre>
  
  <p>Here is my View </p>
  
  <pre><code>@using MathTestApp.Models
  @model MathTestApp.Models.Riddle
  @{
  Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
  var lstChapter = ViewBag.ChapterOpt;
  var referrer = ViewBag.referrer;
  }
  @section heading
  {
  Edit Riddle
  }
  @using (Html.BeginForm("Edit","Riddle",FormMethod.Post)) 
  {
      &lt;input id="referrer" type="hidden" value="@ViewBag.referrer" /&gt;
      &lt;div class="form-horizontal"&gt;
  
      @Html.ValidationSummary(true, "", new { @class = "text-danger" })
      &lt;div class="form-group"&gt;
          &lt;label for="ChapterID" class="col-md-2 control-label"&gt;Chapter&lt;/label&gt;
          &lt;div class="col-md-6"&gt;
              @Html.DropDownListFor(model =&gt; model.ChapterID,new SelectList(lstChapter,"ID","Name"),"-- Chapter --",htmlAttributes: new { @class = "form-control width-180", @id = "ChapterID"})
              @Html.ValidationMessageFor(model =&gt; model.ChapterID, "", new { @class = "text-danger" })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class="form-group"&gt;
          &lt;label for="Content" class="col-md-2 control-label"&gt;Content&lt;/label&gt;
          &lt;div class="col-md-6"&gt;
              &lt;div class=""&gt;
                  @Html.TextAreaFor(model =&gt; model.Content,  new { id="Content", placeholder="Content", @class = "form-control" })
                  @Html.ValidationMessageFor(model =&gt; model.Content, "", new { @class = "text-danger" })
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;label for="Suggestion" class="col-md-2 control-label"&gt;Suggestion&lt;/label&gt;
          &lt;div class="col-md-6"&gt;
              &lt;div class=""&gt;
                  @Html.TextAreaFor(model =&gt; model.Suggestion,  new { id="Suggestion", placeholder="Suggestion", @class = "form-control" })
                  @Html.ValidationMessageFor(model =&gt; model.Suggestion, "", new { @class = "text-danger" })
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="text-center"&gt;
          &lt;a class="btn btn-primary btn-md" href="@referrer"&gt;&lt;i class="fa fa-rotate-left fa-fw"&gt;&lt;/i&gt; Back&lt;/a&gt;
          &lt;button type="submit" id="savebtn" class="btn btn-success"&gt;Save&lt;/button&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  }
  </code></pre>
  
  <p>can you guys tell me how to pass the referrer from Get action method to Post Action method?</p>
  
  <p>Thanks a lot!</p>
  
  <p>P/S: btw I don't wanna create new ViewModel to solve this, is there any other way please tell me.</p>