<p>I have a problem with a sample routing with the preview 5 of asp.net mvc.</p>

<p>In the AccountController I have 2 actions:  </p>

<pre><code>public ActionResult Delete()  
public ActionResult Delete(string username)
</code></pre>

<p>While trying to look for Account/Delete or Account/Delete?username=davide the ControllerActionInvoker throws a exception saying that Delete request is ambiguous between my tow actions methods.</p>

<p>The default route in the global.asax hasn't been changed.</p>

<p>Shouldn't the action invoker understand what's the method to call looking in the parameters list?</p>

<p>Using the preview 4 I hadn't these kind of problem performing the same operation.</p>

<p>Any idea?</p>

[{'answer_id': 47375, 'author': 'berko', 'author_id': 4884, 'author_profile': 'https://Stackoverflow.com/users/4884', 'pm_score': 0, 'selected': False, 'text': "<p>I can't say for sure why this is happening. But you might want to consider only having the Delete(string username) action and removing the parameter-less overload.</p>\n\n<p>Because string is nullable my understanding is that simply calling Account/Delete will invoke the action with a null username parameter which you can then test for at the beginning of the action method.</p>\n"}, {'answer_id': 47418, 'author': 'Davide Vosti', 'author_id': 1812, 'author_profile': 'https://Stackoverflow.com/users/1812', 'pm_score': 3, 'selected': True, 'text': '<p>Solution found!</p>\n\n<p>With the introduction of the ActionNameAttribute, it\'s now necessary to filter manually which method to call depending on the request. This is done by the ActionSelectionAttribute.</p>\n\n<p>Full explanation here: <a href="http://haacked.com/archive/2008/08/29/how-a-method-becomes-an-action.aspx" rel="nofollow noreferrer">http://haacked.com/archive/2008/08/29/how-a-method-becomes-an-action.aspx</a></p>\n'}, {'answer_id': 49187, 'author': 'crucible', 'author_id': 3717, 'author_profile': 'https://Stackoverflow.com/users/3717', 'pm_score': 0, 'selected': False, 'text': '<p>What I\'d do is ditch the blank Delete(), and only use Delete(string username)</p>\n\n<p>In your url routing you\'d have something similar to "/{Controller}/{Action}/{username}/" ?\nIf you have "/{Controller}/{Action}/{Id}/" you\'d be better off doing Delete(string id) and that way just using the url to handle this "/Account/Delete/davide/"</p>\n\n<p>That said use your default route which should be something like the default Id is ""</p>\n\n<p>Then in your Delete(string id) method have:</p>\n\n<pre><code>public ActionResult Delete(string id)\n{\n    if(string.IsNullOrEmpty(id)) return EmptyID();\n\n    // Continue normal Delete method\n}\n\npublic ActionResult EmptyID()\n{\n    // The method you were going to have on a blank delete.\n}\n</code></pre>\n\n<p>That or just wrap it up in the one method on an if {} else {}</p>\n\n<p>Either way I\'d just be going with the one method and doing a default on your username/id in your route of an empty string and handle it that way.</p>\n\n<p>If you want to contact me on further follow up to what I mean, or whatever will help, ping me at andrew@ my domain on my info page.</p>\n\n<p>Edit: Ah pretty much what Berko said anyway, I\'m not sure how Named Attributes would help - so please post a comment here detailing it for other guys who find the same issues! :)</p>\n'}, {'answer_id': 386884, 'author': 'Aristotle Ucab', 'author_id': 31445, 'author_profile': 'https://Stackoverflow.com/users/31445', 'pm_score': 0, 'selected': False, 'text': '<p>Its ambiguous because the two controller action are the same post method..\nYou can only used that in form posting scenario for example you are submitting a form data that uses HTTP post..</p>\n'}]
['https://Stackoverflow.com/questions/47338', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1812/']