What could be the cause of an Index method giving problems?

-3

I'm faced with a problem in my Controller where my Index method keeps bringing a null value when it has to start.

Controller

public ActionResult Index()
{
    return View();
}

I tried doing the following as another way of debugging it...

public ActionResult Index()
{
    try
    {
        return View();
    }
    catch (Exception ex)
    {
        throw;
    }
}

It still brings null results and breaks on a View at this part

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

with this error message...

System.NullReferenceException HResult=0x80004003 Message=Object reference not set to an instance of an object.
Source=App_Web_vcfmo4xc StackTrace: at ASP._Page_Views_OfficeSupply_Index_cshtml.Execute() in C:\Users\Motse Mohapi\source\repos\MGroup_Website\taskmanagementlog\Views\OfficeSupply\Index.cshtml:line 4 at System.Web.WebPages.WebPageBase.ExecutePageHierarchy() at System.Web.Mvc.WebViewPage.ExecutePageHierarchy() at System.Web.WebPages.StartPage.RunPage() at System.Web.WebPages.StartPage.ExecutePageHierarchy() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)

What could I be missing here? Can anyone please help!

c#
model-view-controller
asked on Stack Overflow Nov 2, 2018 by MotseMo

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0