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));
}
}
}