I came across an issue when coding methods in a controller that have separate Get and Post executions. Normally when we scaffold a controller against a model, the Get and Post methods have different parameter definitions because the Post method is normally capturing data from the form to save to the model/database.
But I was just coding an original set of Get/Post methods where the parameter list was actually the same. I can later post my example code to show this, but that might be distracting from my question; i.e., we can acknowledge there's always another way to code any given method. In this case, I'd rather get an answer to this question.
If the Get and Post methods have the same parameter definition, then that's a syntax error. So I needed a way around this problem. The following was my logic.
Since I can't change the name of the method (that's an assumption on my part that may not be valid), the only way around this is to change the parameter definition of one or the other of the Get/Post variations. So I added an additional parameter to the Get method and the compiler was happy. I don't actually supply that parameter when invoking the method, and of course I don't use the parameter in the method, but it does give the method a different parameter definition and it solved my dilemma.
But I wanted to ask if everyone else handles this coding issue different ways so I might learn a better way to do it. It may be that my assumption about method naming is incorrect as well.
Added after original post: (@CodeCaster, lesson learned). I removed the internal code as it's not related:
Function ChannelTopicSelector(ByVal ChannelType As ChannelType, ByVal Topic As String) As ActionResult
Return View()
End Function
<HttpPost()>
<ValidateAntiForgeryToken()>
Function ChannelTopicSelector(ByVal ChannelType As ChannelType, ByVal Topic As String) As ActionResult
Return View()
End Function
The first method above returns the 'multiple definitions with identical signatures' error.
I followed CodeCaster's link which I believe is also Brad's point and I understand how the ActionName Attribute is applied. I hadn't noticed this before as my coding never got into yet.
Regards the duplicate question, I did look for other posts, I just didn't know how to frame the question correctly for it to come up in the search. Should this post be deleted then? Anyway, my question is answered - thx