Click here to Skip to main content
15,904,155 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am new on MVC, and I am Getting following error while rendering partial view with controller.

Execution of the child request failed. Please examine the InnerException for more information.

and in innerException showing this:

The controller for path '/' was not found or does not implement IController.

Please help me guys......


Here is my DataContract Class

C#
namespace DataContracts
{

    public class StoryWidget
    {
        public string SportName { get; set; }
        public string imageURL { get; set; }
        public string SportTitle { get; set; }
        public string SeriesTitle { get; set; }
        public string AuthorName { get; set; }
    }
}


Here is my Controller

Controller
C#
public class StoryController : Controller
    {
        //
        // GET: /Story/

        [ChildActionOnly]
        public ActionResult _StoryWidgetPartial(string SName)
        {
            var model = new List<StoryWidget>();
            if (model != null)
            {
                StoryWidget item = new StoryWidget() { SportName = SName, SeriesTitle = "IPL 2013", SportTitle = "ICC Hall" };
                model.Add(item);
            };
            return View(model);
        }
    }


Here is my Partial View :

@model DataContracts.StoryWidget


<div class="nw-img">
                   @*@foreach (var item in Model)
                   {*@
                       <div class="col-6">
                           <a href="#" title="@Model.SportTitle">
                               <img src="images/football_1.jpg" alt="Waqar, Gilchrist indeucted into ICC Hall of Fame"
                                   title="Waqar, Gilchrist indeucted into ICC Hall of Fame" /></a>
                       </div>
                   @*}*@
                   </div>



And I am Calling this partial from my _Layout.cshtml :

@{Html.RenderAction("_StoryWidgetPartial", "StoryController", "Cricket");}



I am Getting this exception at this above Line("
@{Html.RenderAction("
)

Execution of the child request failed. Please examine the InnerException for more information.

and in innerException showing this:

The controller for path '/' was not found or does not implement IController.

Please help me guys......
Posted

1 solution

I have fixed my self:

Problem was on calling in
@{Html.RenderAction("
Method.

I have just removed controller text from the passing controller name.

@{Html.RenderAction("_StoryWidgetPartial", "Story", new { SName= "Cricket" });}


above code work for me.
 
Share this answer
 
v2

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