Avatar of Charles Baldo
Charles Baldo
Flag 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
ASP.NETC#.NET Programming

Avatar of undefined
Last Comment
Charles Baldo

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
David Johnson, CD

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Charles Baldo

ASKER
David,

Thanks, I got it about a half hour after I posted this.  I have it working now
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck