Link to home
Start Free TrialLog in
Avatar of Charles Baldo
Charles BaldoFlag for United States of America

asked on

MVC 5 Routing Question

I am an MVC newbie

I have a controller that feeds from a view  I am using route attributes

View Index


The categories and documents are read from a database that is generate in another view

@foreach (var item in Model.ArticleList)
{
         <a href="/Article/@item.Category/@item.document">Read More...</a>
}

-------------- Controller ------------------------- with route attributes

        [Route("Article/{Category}/{Document}")]
        public ActionResult  Article(String Category, String Document)
        {                
            ..... Read data in ...............
            ...... get data from model for  Article To Display
            ..........................................
            return View(Model  ArticleToDisplay);
        }


I have dozens of categories and hundreds of documents and the categories are growing in the database

I need one view that I can pass the values and display it. There is no way I can physically create a view for each controller.

Lets say one of the categories is RootCauseAnalysis and a document is Equipment-Operators-Improve-Reliability  what I get is

The view 'Article/RootCauseAnalysis/Equipment-Operators-Improve-Reliability' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Article/Article/RootCauseAnalysis/Equipment-Operators-Improve-Reliability.aspx
~/Views/Article/Article/RootCauseAnalysis/Equipment-Operators-Improve-Reliability.ascx
~/Views/Shared/Article/RootCauseAnalysis/Equipment-Operators-Improve-Reliability.aspx


How can I get around not making a view for each category???


Thanks
ASKER CERTIFIED SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Charles Baldo

ASKER

David,

Thanks, I got it about a half hour after I posted this.  I have it working now