Home > Enterprise >  System.NullReferenceException HResult=0x80004003 Message=Object reference not set to an instance of
System.NullReferenceException HResult=0x80004003 Message=Object reference not set to an instance of

Time:01-03

I have an error when trying to run my MVC ASP.NET C# web application for the shared layout razor page. The error I faced is at the code:

 <div >
        <div >
            <button type="button"  data-toggle="collapse" data-target=".navbar-collapse" id="make-small-nav">
                <span ></span>
                <span ></span>
                <span ></span>
            </button>
            @if (System.Configuration.ConfigurationManager.AppSettings["Applicant Tracking System"].ToLower().ToString() == "true")
            {
                @Html.ActionLink("Applicant Tracking System"   @System.Configuration.ConfigurationManager.AppSettings[""], "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
            }
            else
            {
                @Html.ActionLink(@System.Configuration.ConfigurationManager.AppSettings["Applicant Tracking System"], "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
            }

        </div>
        <div style="float:right">
            @if (Session["username"] != null)
            {
               <text> Welcome, @Session["username"].ToString()!</text><span>
                    &nbsp;&nbsp;
                    @Html.ActionLink(" ", "Index", "Home", new { area = "" }, new { @class = "fa fa-sign-out fa-2x" })
                </span>
            }
        </div>
    </div>

I was expecting to make a menu button to hover down the side bar menu for the code:

        <div >
            <div >
                <div >
                    <div >MASTER MAINTENANCE</div>
                    <div >
                        <a  role="button" href="@Url.Action("PositionList", "Position")"><span ></span> <b>MM POSITION</b></a>
                    </div>
                    <div >
                        <a  role="button" href="@Url.Action("CandidateList", "Candidate")"><span ></span> <b>MM CANDIDATE</b></a>
                    </div>
                    <div >INTERVIEW TRACKING</div>
                    <div >
                        <a  role="button" href="@Url.Action("Index", "Interview")"><span ></span> <b>INTERVIEW</b></a>
                    </div>
                </div>
            </div>
        </div>

Is there any ways to fix this issue?

CodePudding user response:

possible null return System.Configuration.ConfigurationManager.AppSettings[KeyName] If KeyName Not Exists In AppSettings

Please Check your web.config appsettings section.

  • Related