user2620804
user2620804

Reputation: 133

Redirect to action causing 404

Controller

        [HttpPost]
    public ActionResult Index(string Name, int number)
    {
        Stored stored = new Stored();
        var isValid = from c in _db.stored
                      where (c.Name == Name && c.Id == number)
                      select c;


        if (isValid.Count() > 0)
        {
            return View("Index");
        }
        else if (isValid.Count() > 0 && c.hasExpired)
        {
            return RedirectToAction("Send", "Mail", new { theNumber = number });
        }
        else
        {
            return View("Index");
        }
    }

Target class

[HttpPost]
public ActionResult Send(int number)

Both have the HTTP Post attribute

Upvotes: 0

Views: 1712

Answers (2)

user2620804
user2620804

Reputation: 133

Using [HttpGet] solved the issue

Upvotes: 2

Mahmmoud Qassem
Mahmmoud Qassem

Reputation: 283

check from Controller Name; and you need to use [HTTPPOST] befor the function.
example :

[HTTPPOST]
public ActionResult Send(int number)
{
  return RedirectToAction("Send", "Mail", new { theNumber = number });
}

Upvotes: -2

Related Questions