0

I have a bootstrap Side Menu with the following menu item

<li class="treeview">
    <a href="#">
        <i class="fa fa-files-o"></i> <span>Reporting</span> <i class="fa fa-angle-left pull-right"></i>
    </a>
    <ul class="treeview-menu">
        <li>
            <a href="@Url.Action("Enquiries", "Enquiry", new {captureQuote = false})"><i class="fa fa-circle-o"></i> Enquiries</a>
        </li>
    </ul>
</li>

Problem is when I click it that it will route to /Enquiry/Enquiries?captureQuote=True

I only want it to show /Enquiry/Enquiries Currently I am using the following workaround in the Controller but it is messy and it will display /Enquiry/EnquiryList

    [HttpGet]
    public ActionResult Enquiries(bool captureQuote)
    {
        Session["Q"] = captureQuote;
        return RedirectToAction("EnquiryList");
    }

    public ActionResult EnquiryList()
    {
        var captureQuote = (bool)Session["Q"];
        return View("Enquiries",new EnquiriesModel()
        {
            CanDoQuote = captureQuote
        });
    }

What is a better option to do this?

user2771704
  • 5,994
  • 6
  • 37
  • 38
Donald Jansen
  • 1,937
  • 4
  • 22
  • 41
  • 1
    This [SO question](http://stackoverflow.com/questions/21552117/how-to-remove-the-querystring-parameters-in-url-in-mvc4-with-razer-using-url-act) has some useful info, You cannot get rid of having some data in the querystring, but you can make the url look cleaner. – Jason Evans Nov 06 '15 at 08:47

1 Answers1

-1

You could use POST instead of GET. So you could replace the link with a form containing hidden fields for the parameters that you don't want to appear in the query string:

@using (Html.BeginForm("ActionName","ControllerName"))
{
     @Html.Hidden("ID",value)

     <button type="submit">Submit</button>
}
Aizaz Ahmed
  • 210
  • 1
  • 6