Muhammad Shaikh

Muhammad Shaikh

  • NA
  • 46
  • 1.2k

How to execute the API and then redirect to some other page in project

May 10 2021 9:46 AM
am stuck in a problem, whenever I submit, it is going to a blank page to execute api.
 
I want, it should execute API and then redirected to another page.
 
How can I do that,
 
My cshtml code is below
  1. @model CourseGamePlay.Dtos.StudentsDTO  
  2. @{  
  3. ViewBag.Title = "Admin Panel - Weeks";  
  4. Layout = "~/Views/Shared/_adminLayout.cshtml";  
  5. }  
  6.   
  7. <h2>LOGIN</h2>  
  8. <body>  
  9. <form method="post" action="/api/studentlogin">  
  10. <div class="form-horizontal">  
  11. <div class="form-group">  
  12. @Html.LabelFor(s => s.name, htmlAttributes: new { @class = "control-label col-md-2" })  
  13. <div class="col-md-4">  
  14. @Html.EditorFor(s => s.name, new { htmlAttributes = new { @class = "form-control" } })  
  15. @Html.ValidationMessageFor(s => s.name, ""new { @class = "text-danger" })  
  16. </div>  
  17. </div>  
  18. <div class="form-group">  
  19. <div class="col-md-offset-2 col-md-15">  
  20. <input type="submit" value="Login" class="btn btn-primary"/>  
  21. </div>  
  22. </div>  
  23. </div>  
  24. </form>  
  25. </body>  
  26. @* <script>  
  27. $(function(){  
  28. $("#redirect").click(function (e) {  
  29. e.preventDefault();  
  30. document.location = '@Url.Action("Week","Home")';  
  31. });  
  32. });  
  33. </script> *@  

Answers (1)