Link to home
Start Free TrialLog in
Avatar of Crystal Rouse
Crystal RouseFlag for United States of America

asked on

How to update Methods to use HttpPost instead of HttpPost to resolve security concerns.

I have some methods in Controllers that I need to update to use the action verb [HttpPost] instead of [HttpGet].  When I do this, the code in the View no longer works.
Here is an example:

The Controller has the following method:

 [HttpGet]
            public ActionResult MoveToReview(int id)
            {
                  tbl_BOM bom = (from x in bomDB.tbl_BOM
                                       where x.ID == id
                                       select x).Single();

                  bom.SetStatus(tbl_Status.getStatusID("Review"));
                  return RedirectToAction("Details", new { id = id });
            }

The View uses this in a button:

<button class="btn btn-success col-xs-6 col-xs-offset-3" onclick="window.location = '@Url.Action("MoveToReview", "Report", new { id = Model.id })';">
                            Move To Review
                        </button>


If I update to use [HttpPost], I get an error.
SOLUTION
Avatar of zephyr_hex (Megan)
zephyr_hex (Megan)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial