Link to home
Start Free TrialLog in
Avatar of sai krishnan
sai krishnanFlag for India

asked on

"The resource cannot be found"

i am new to asp.net mvc.i have tried to give a action method for redirecting to another action method method but it throwing this error.i have attached the code below


design code


<table>

    <tr>
        <td>

            @Html.ActionLink("Register", "Index")
        </td>

    </tr>

</table>
@using (Html.BeginForm())
{
    <table>
        <tr>
            <td>
                @Html.LabelFor(m => m.username)
            </td>

        </tr>
        <tr>
            <td>
                @Html.TextBoxFor(m => m.username)
                @Html.ValidationMessageFor(m => m.username)
            </td>

        </tr>
        <tr>
            <td>
                @Html.LabelFor(m => m.Password)
            </td>

        </tr>
        <tr>
            <td>
                @Html.TextBoxFor(m => m.Password)
                @Html.ValidationMessageFor(m => m.Password)
            </td>

        </tr>
        <tr>
            <td>
                <input type="submit" id="submit" value="submit" />

            </td>

        </tr>
    </table>

}



controller code

  public class HomeController : Controller
    {
        // GET: Home
        public ActionResult Index()
        {
            return View();
        }
        [HttpPost]
        public ActionResult Index(Customer cus)
        {
            using (customerEntities1 ce = new customerEntities1())
            {
                try
                {
                    if (ModelState.IsValid)
                    {

                        Customer cs = new Customer();

                        ce.Customers.Add(cus);
                        ce.SaveChanges();
                        ViewBag.alert = cus.username + " recoords are insered successfully";
                        ModelState.Clear();
                    }
                }
                catch (DbEntityValidationException dbEx)
                {
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            Trace.TraceInformation("Property: {0} Error: {1}",
                                                    validationError.PropertyName,
                                                    validationError.ErrorMessage);
                        }
                    }
                }

            }
            return View();
        }
     
        [HttpPost]
        public ActionResult welcome(Customer cus1)
        {
            using (customerEntities1 ce = new customerEntities1())
            {
                var obj1 = from e in ce.Customers where e.username == cus1.username && e.Password == cus1.Password select e.username;
                if (obj1 != null)
                {

                    RedirectToAction("welcome");


                }
                else
                {


                    ViewBag.mes = "your user and password is not correct";
                }
                return View();
            }
        }
    }

it is not redirecting to welcome action method.please help on this
1.jpg
ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial