Click here to Skip to main content
15,895,462 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a data-driven website.

To implement a search feature, I iterate through the record (there are too few to bother indexing), look for the search text in important fields, assign a score, and voila -- search results that can be sent to a view to render.

There are a few pages that are not data driven. They are essentially static text (privacy policy, about us, etc.) that live in their own Razor views. These are therefore not searched currently.

I had hoped that I could just instantiate a controller, tell it to render these views as strings, search them and I'd be on my way. That isn't the case. After a few hours of trying, I haven't been able to make this work. The main problem is that you can't do this without a ControllerContext, and you can't just create one.

I could actually read the views from the filesystem, but that's icky and would also contain code and metadata.

Is this possible, or do I need to rethink the way I'm presenting static content?
Posted

1 solution

I have a similar issue, and by moving the static content to a Table/Library which has a view/medium to maintain. Thus giving you 2 advantages.
#1. maintainability, as its not directly hardcoded on view.
#2. Searchable, as its now data driven.
 
Share this answer
 

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