Guest User

Guest User

  • Tech Writer
  • 2.1k
  • 472.4k

How to make your create work in your MVC web?

Jan 23 2020 3:14 PM
Hi Mate
 
I have login.cshtml page and it has login button(this works), but my create button does not(how do i make an implementation for this to allow users be created)? I have this flow below from my Views/Account/login.cshmtl;
  1. <div data-="mainContent">  
  2. <section class="container">  
  3. <div class="logo col-sm-12 text-center col-md-12"> <img alt="" src="~/Images/eNtsa.png" /></div>  
  4. <div class="clearfix"></div>  
  5. <div class="container">  
  6. <div class="row">  
  7. <div id="MyWizard" class="formArea LRmargin">  
  8. @using (Html.BeginForm())  
  9. {  
  10. @Html.AntiForgeryToken()  
  11. <div id="divMessage" class="text-center col-md-12 col-md-offset-12 alert-success">  
  12. @Html.ValidationSummary()  
  13. </div>  
  14. <div class="glyphicon-log-out col-sm-12 text-center col-md-12"> <img alt="" src="~/Images/gcobani.jpg" /></div>  
  15. <div class="clearfix"></div>  
  16. <div class="col-md-12 col-md-offset-10 col-xs-12">  
  17. <div class="loginPage panel-info">  
  18. <span class=""><i class="glyphicon glyphicon-user">Username</i></span>  
  19. <div class="form-group text-center">  
  20. @Html.TextBoxFor(model => model.username, new { @class = "form-control text-center", autocomplete = "off" })  
  21. @Html.ValidationMessageFor(model => model.username)  
  22. </div>  
  23. <div class="form-group">  
  24. <span class=""><i class="glyphicon glyphicon-user">Password</i></span>  
  25. @Html.PasswordFor(model => model.password, new { @class = "form-control text-center", autocomplete = "off" })  
  26. @Html.ValidationMessageFor(model => model.password)  
  27. </div>  
  28. </div>  
  29. <div class="form-group">  
  30. <input id="BtnLogin" type="submit" class="btn btn-success btn-pressure" name="BtnLogin" value="Login" />  
  31. <input id="BtnReset" type="reset" value="Create" class="btn btn-info btn-pressure" name="BtnReset" value="Reset" />  
  32. </div>  
  33. </div>  
  34. }  
  35. <div class="clear"></div>  
  36. </div>  
  37. </div>  
  38. </div>  
My Question do i have to create this first on my Routing.cs under AppStart folder, i notice my login is routing there? Also have i created a method create on my Controller. See this below
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Web;  
  5. using System.Web.Mvc;  
  6. using System.Web.Routing;  
  7. namespace eNtsaPortalWebsiteProject  
  8. {  
  9. public class RouteConfig  
  10. {  
  11. public static void RegisterRoutes(RouteCollection routes)  
  12. {  
  13. routes.IgnoreRoute("{resource}.axd/{*pathInfo}");  
  14. routes.MapRoute(  
  15. name: "Default",  
  16. url: "{controller}/{action}/{id}",  
  17. defaults: new { controller = "Account", action = "Login", id = UrlParameter.Optional }  
  18. );  
  19. }  
  20. }  
  21. }  

Answers (1)