简体   繁体   中英

The model item passed into the dictionary is of type 'System.Threading.Tasks.Task`1[System.Collections.Generic.IEnumerable`

I am getting the following error while running my mvc application :

{"The model item passed into the dictionary is of type 
'System.Threading.Tasks.Task`1[System.Collections.Generic.IEnumerable`
1[PM.CManager.Clm.Domain.Models.Ln]]', b
ut this dictionary requires a model item of type 'PM.CManager.Clm.Domain.Models.Ln'."}

Below is my controller return value:

 public ActionResult ClaimDetail()
        {
            //return View();
            string id = "1000000246";
             if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            var LnDetail = _LnProxy.GetLnDetailByLnNum((string)id);
            if (LnDetail == null)
            {
                return HttpNotFound();
            }
            return View(LnDetail);
        }

Below is my view :

@model PM.CManager.Clm.Domain.Models.Ln
   @using (Html.BeginForm())
   {
       <div class="panel panel-primary">

           <div class="panel-heading inform" style="">
               <table clases="panel-title inform">
                   <tr>
                       <td class="inform">Ln Number: <label id="Lnnum" name="Lnnum">1000100001</label></td>
                       <td class="inform">Status: <label id="Lnstatus" name="Lnstatus">Forclosure</label></td>
                       <td class="inform">Ln Type: <label id="Lntype" name="Lntype">Government(FHA)</label></td>
                   </tr>
               </table>
           </div>

What is the possible change need to do for below line to fix this issue?

@model PM.CManager.Clm.Domain.Models.Ln

It seems like you are returning a Task form this line:

var LnDetail = _LnProxy.GetLnDetailByLnNum((string)id);

This needs to be changed to:

var LnDetail = await _LnProxy.GetLnDetailByLnNum((string)id);

Then you needs to change the signature of the method to:

public async Task<ActionResult> ClaimDetail() { /* ... */ }

Also bear in mind if its a collection or single item that comes though and adjust your view accordingly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question The model item passed into the dictionary is of type '` but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable' The model item passed into the dictionary is of type .. but this dictionary requires a model item of type System.Collections.Generic.IEnumerable' The model item passed into the dictionary is of type , but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable The model item passed into the dictionary is of type, but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable The model item passed into the dictionary is of type , but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable The model item passed into the dictionary is of type, but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable` The model item passed into the dictionary is of type 'System.Linq.GroupedEnumerable`3 but this requires 'System.Collections.Generic.IEnumerable`1 cannot convert from System.Collections.Generic.List<sales.ScanInfo> to System.Collections.Generic.IEnumerable<System.Threading.Tasks.Task> The model item passed into the dictionary is 'System.Data.Entity.Infrastructure.DbQuery`, but requires 'System.Collections.Generic.IEnumerable 'System.Collections.Generic.List`1[<>f__AnonymousType1 but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable ERROR
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM