Bindowanie danych nie działa-Helpery Html ASP.NET MVC

0

Witam po zastosowaniu formularza z Html.Helperami i wysłaniu danych na localhosta nie jest zwracany zdefiniowany ActionResoult z wynikami. Przeładowywany jest jedynie widok. Dziwne jest to, że przykład pochodzi z kursu wideo, na którym lektor pisze dokładnie ten sam kod. Wszystko elegancko działa jak formularz jest napisany w formie HTML. Proszę o wskazówki i z góry dziękuję :)

RouteConfig.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace WebApplication3
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}",
                defaults: new { controller = "Home", action = "Index" }
            );

        }
    }
}
 

Index.cshtml

@model WebApplication3.Models.HelpersModel

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
</head>
<body>
    <div> 


        @using (Html.BeginForm())
        {
            @Html.TextBoxFor(model => model.Name)


            @Html.TextBoxFor(model => model.Surname)


            @Html.TextBoxFor(model => model.Tel)

            <input type="submit" value="Wyślij" />
        }
    </div>
</body>
</html>
 

HelpersModel.cs

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WebApplication3.Models
{
    public class HelpersModel
    {
        public string Name { get; set; }

        public string Surname { get; set; }

        public string Tel { get; set; }
    }
}

HomeController

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebApplication3.Models;

namespace WebApplication3.Controllers
{
    public class HomeController : Controller
    {
        // GET: Home
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult ViewResoult (HelpersModel model)
        {

            return Content(string.Format("{0}{1}{2}", model.Name, model.Surname, model.Tel));
        }

        
    }
} 
1

Nigdzie przy tworzeniu formularza nie podajesz do jakiej akcji uderzasz więc domyślnie jest wykonywana akcja z taką samą nazwą jak na, która wyświetliła ten formularz. Domyślam się patrząc na kod kontrolera, że formularz masz na stronie /Home/Index, zaś w formularzu chcesz wysłać dane do /Home/ViewResult. Coś w tym stylu powinno zadziałać:

using (Html.BeginForm("ViewRsult", "Home", PostMethod.Get)) 
1

Powinno być:

public ActionResult Index(HelpersModel model)

1 użytkowników online, w tym zalogowanych: 0, gości: 1