mvc Details receives a null value

0

Use VS 2015. I have a list of clients. When I choose one, when I get to Details I notice that the user_name field arrives null.

private salon_de_belleza_bd2Entities db = new salon_de_belleza_bd2Entities();
 public ActionResult Index()
        {            
            return View(db.tbl_clientes.ToList());
        }

        // GET: Clientes/Details/5
        public ActionResult Details(string nombre_usuario)
        {
            if (nombre_usuario == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }

Use stored procedures and first base data

    
asked by Jhon Hernández 17.04.2018 в 18:43
source

1 answer

0

If in the default path of the application, defined in App_Start / RouteConfig.cs, you have something similar to this:

routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );

You may be making a request such as "Clients / Details / 5", but the default parameter is called "id".

If this is the case you could do two things, change the name of the method parameter "Details", from "username" to "id", or make a request to "Customers / Details? username = 5"

    
answered by 17.04.2018 в 19:25