Confused with typical functionality. Help me to understand. There are inputs that I have combined into a form.
<div> <form name="ticketForm" novalidate ng-submit="submit()"> <div> <label>Пункт отправления</label> <input type="text" name="depature" ng-model="ticket.Depature" required /> </div> <div> <label>Пункт назначения</label> <input type="text" name="destination" ng-model="ticket.Destination" required /> </div> <div> <label>Дата вылета</label> <input type="date" name="departureDate" ng-model="ticket.DepatureDate" required /> </div> <div> <label>Дата возвращения</label> <input type="date" name="returnDate" ng-model="ticket.ReturnDate" required /> </div> <input type="submit" value="Save" ng-disabled="ticketForm.$invalid"> </form> </div> This is how I send the form:
$scope.submit = function () { $http({ method: 'POST', url: '/home/Result', params: $scope.ticket, headers: { 'Content-Type': 'application/json' } }) } Further, what I want to do is: on the controller side, calculations must be performed, which will be derived by changing the window. That is, a redirect should actually occur. But the controller method:
public ActionResult Result(TicketInputData inputData) { var bestOffer = new TicketOutputData() { MinCost = 0.1, CompanyName = "Trololo", DepartureFlightNumber = "666", DepartureTime = DateTime.Today, ReturnFlightNumber = "13", ReturnStartTime = DateTime.Today.AddDays(10) }; ViewBag.outputParams = bestOffer; return View("Result"); } It does not lead to it. If I understand correctly, the View is created, but the transition does not occur. I used to do this through location.href ..., but now I’ll have to push too many parameters to the end of the URL. Tell me how to make the transition to the formed View.
And this also does not work:
public RedirectToRouteResult FindResult(TicketInputData inputData) { System.Net.WebClient web = new System.Net.WebClient(); web.Encoding = UTF8Encoding.UTF8; string str = web.DownloadString("https://search.aviasales.ru/MOW2405ATH30061"); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(str); var bestOffer = new TicketOutputData() { MinCost = 0.1, CompanyName = "Trololo", DepartureFlightNumber = "666", DepartureTime = DateTime.Today, ReturnFlightNumber = "13", ReturnStartTime = DateTime.Today.AddDays(10) }; //ViewBag.outputParams = bestOffer; //return View("Result"); return RedirectToActionPermanent("ViewResult", "Home", bestOffer); } public ActionResult ViewResult(TicketOutputData bestOffer) { ViewBag.outputParams = bestOffer; return View("Result"); }