Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

101
Views
Window.history.pushState muestra la URL original con un flash antes de cambiar a lo que se ha definido

Mi proyecto usa ASP.NET MVC. Tengo un formulario en mi archivo cshtml en el que, si lo envío, llama a una acción específica en el controlador. No quiero que el nombre de la acción aparezca en la URL. Entonces usé window.history.pushState para cambiar la URL a la predeterminada. Pero en realidad, cuando presiono el botón de enviar en el formulario, la URL real con el nombre de la acción aparece en un instante en la barra de direcciones antes de cambiar a la especificada. ¿Cómo soluciono este problema, por favor? Gracias :)

Cshtml

 @using (Html.BeginForm("Step2", "Restaurants",FormMethod.Post)) { @Html.AntiForgeryToken() <div class="container"> <div class="form-horizontal"> <div class="input- group"> @Html.TextBoxFor(m => m.FoodName, new { @class = "form-control}) </div> <button type="submit" class="btn nextBtn">Next </button> </div> </div> }

Controlador de Restaurantes

 Restaurant res = new RestaurantDetails(); public ActionResult Index() { ViewBag.Step = 1; ViewBag.Title = "MAIN COURSE"; mymodel.Restaurant = RestaurantList.Where(x => x.Id == “1234”.FirstOrDefault(); return View(res); }

[HttpPost] [ValidateAntiForgeryToken] Public ActionResult Step2 (Alimento foodItem) { ViewBag.Step = 2; ViewBag.Title = "CURSO PRINCIPAL"; }

Índice.cshtml

@if (VerBolsa.Paso == 1) {

@Html.Partial("~/Vistas/Menú/_Starters.cshtml") }

 @if (ViewBag.Step == 2) { @Html.Partial("~/Views/Menu/P artials/_MainCourse.cshtml", Model) }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!