MVC 5 Routing Question

Charles Baldo
Charles Baldo used Ask the Experts™
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

        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:

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

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016
you don't need a separate view for each model. You seem to be making an error in thinking every category requires a distinct model you would use the category as a variable that will be passed to the controller the controller will pass data back to the model which will then pass the data back to the view
Charles BaldoSoftware Developer



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

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial