2

Ok so i have a snippet which is supposed to redirect to a controller's action.

return RedirectToAction("add");

Now the problem is that add action is overloaded. One which gets called when the HTTPrequest is of GET type and the other when the request is of POST type. Is there anyway that i can select to which action does the statement redirect ?

2 Answers 2

3

RedirectToAction returns a 302 (moved) response to your client's browser. GET is the only method you'll get out that.

If you were asking because you WANT to invoke your POST/add action, this related question might help

Sign up to request clarification or add additional context in comments.

Comments

0

Try this

[AcceptVerbs(HttpVerbs.Get)]
public ActionResult add()
{
    ...
}

[ActionName("add")]
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult add_post()
{
    ...
}

This way you can POST and GET to add and in the controller you call add or add_post

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.