I'm new to .NET and C#, having trouble routing to my one view file on app start. There must be something I don't understand about the routing, because the URL in the browser:
/Views/LoadCustomerAndDisplay/Index.cshtml
seems right to me. However, I get a 404 error when I build and run the app. Here is a picture of the file structure:
and here is the browser error:
RouteConfig
:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace WebApplication6
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { action = "Index", id = UrlParameter.Optional }
);
}
}
}
LoadCustomerAndDisplayController
:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebApplication6.Models;
namespace WebApplication6.Controllers
{
public class LoadCustomerAndDisplayController : Controller
{
// GET: LoadCustomerAndDisplay
public ActionResult Index()
{
Customer objCustomer = new Customer();
objCustomer.Id = 1001;
objCustomer.CustomerCode = "C";
objCustomer.Amount = 900.78;
return View(objCustomer);
}
}
}
what am i missing here?