0

What method the Html.Action use for rendering a partial views ?

Example 1 (with parameters):

@Html.Action("_PartialGetMemo", "Memos", new { id = 0 })

Example 2 (without parameters):

@Html.Action("_PartialGetMemo", "Memos")

Can somone explain how this works please ?

Terai
  • 311
  • 1
  • 4
  • 13
  • If the current request is a GET, then it will be a GET. If the current request is a POST, then it will look for a POST method first (and use that if it exists), then for a GET method –  Sep 27 '18 at 12:06
  • 1
    Related: [Html.Action - Get versus Post](https://stackoverflow.com/q/6554960/1220550) – Peter B Sep 27 '18 at 12:08
  • Okay, thanks everyone So there is no way to force it to use a specific method.. – Terai Sep 27 '18 at 12:13
  • What do you mean _force it to use a specific method_? - you are calling the `_PartialGetMemo()` method –  Sep 27 '18 at 12:14
  • what i want is to know if my method was called by HttpPost or HttpGet..because i would like to add a filter on my controller [HttpPost] or [HttpGet] – Terai Sep 27 '18 at 12:18
  • 1
    If you want to always call a `[HttpGet] _PartialGetMemo()` method, then you just need to make sure that you do not also have a `[HttpPost]` method named `_PartialGetMemo` –  Sep 27 '18 at 12:21
  • Thanks @StephenMuecke – Terai Sep 27 '18 at 12:25

1 Answers1

-1

This Html.Action renders partial view as an HTML string so we can store it in another string variable. It is string return type method so first it returns result as a string then renders result to response.