asp.net mvc 5 - System.Web.HttpException / Converting code to proper MVC architecture -


my team have been working on building comment section school project , render in partial view.

this solution came with:

on index page:

@html.partial("statuswall", new project.services.statusservices()) 

statuswall:

@model project.services.statusservices  @foreach (var status in model.getalluserstatuses()) {... 

code in statusservice:

public list<userstatus> getalluserstatuses()     {         //check         var statusresult = (from status in db.userstatuses                             orderby status.dateinserted descending                             select status).tolist();         return statusresult;     } 

this works, problem we're not using proper mvc architecture, since we're bypassing controller. since design of our project requires use partial view, had no idea how call controller, until assistant pointed out [childactiononly] attribute

now, i'm trying incorporate code mvc model solution, far, eludes me.

here's i've written in controller:

    [childactiononly]     public actionresult statuswall() {         var service = new statusservices();         var result = service.getalluserstatuses();         return partialview(result);     } 

index page:

@html.action("statuswall") 

all other code unchanged.

this tosses following error:

an exception of type 'system.web.httpexception' occurred in system.web.dll not handled in user code

additional information: error executing child request handler 'system.web.mvc.httphandlerutil+serverexecutehttphandlerasyncwrapper'.

can explain me i'm doing wrong?

i realized wrong.

i changed...

@model project.services.statusservices  @foreach (var status in model.getalluserstatuses()) {... 

...into...

@model list<project.models.userstatus>  @foreach (var status in model) {... 

there minor fixing, turning actionresult partialviewresult, don't know if necessary code work.


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -