Click here to Skip to main content
15,844,498 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I am getting below error while going from one razor page to another:-

Quote:
An unhandled exception occurred while processing the request.
NullReferenceException: Object reference not set to an instance of an object.
testCRM.Pages.Leads.Pages_Leads_List.<executeasync>b__9_0() in List.cshtml, line 0


Quote:
When i am clicking on the leads button. I am getting above error.


What I have tried:

page 1:-


@page
@model testCRM.Pages.Users.ListModel
@{
}
<h2>List of employess</h2>
<h3>@HttpContext.Session.GetString("Message")</h3>

<form>
    <table border="1">
        <tr>
          <td><a asp-page="/Leads/List">Leads</a></td>

        </tr>
    </table>
<table>
    <tr>
        <th>User FName</th>
        <th>User LName</th>
        <th>User EMAIL</th>
        <th>Action</th>
    </tr>
    @foreach(var User in Model.User)
    {
        <tr>
            <td>@User.UserFName</td>
            <td>@User.UserLName</td>
            <td>@User.UserEmail</td>
             <td><a asp-page="Update" asp-route-id="@User.ID" class="linkbutton">Update</a></td>
             <td><a asp-page="Delete" asp-route-id="@User.ID" class="Linkbutton">Delete</a></td>
        </tr>
    }
</table>
</form>


PAge 2: -
@page
@model testCRM.Pages.Leads.ListModel
@{
    <form method="post">
      <table>
      <tr>
        <th>Name</th>
        <th>Status</th>
        <th>CompanyName</th>
        <th>EmailAddress</th>
        <th>Phone</th>
        <th>AssignUsers</th>
         <th>CreateDate</th>
      </tr>
      
       @foreach(var item in Model.Leads)
            {
              
                <tr>
                <td>@item.FIRST_NAME</td>
                <td></td>
                <td></td>
                <td>@item.EMAIL1</td>
                <td>@item.PHONE_MOBILE</td>
                <td>@item.ASSIGNED_USER_ID</td>
                <td></td>
                </tr>
            }

      </table>
    </form>
}
Posted
Updated 8-Jun-23 15:37pm
v2
Comments
Graeme_Grant 9-Jun-23 1:18am    
You have not posted the server side code that uses this page, so we can't see what is happening.

You can check very quickly and easily what is happening on the server side. Set a debug breakpoint on the server side before serving up the page and inspect the ListModel data to see what is happening.
dattaprasaddhuri 11-Jun-23 8:47am    
ok

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900