Click here to Skip to main content
11,933,037 members (53,901 online)
Rate this:
Please Sign up or sign in to vote.
See more: .NET MVC Razor
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 2-Jul-13 11:10am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web04 | 2.8.151126.1 | Last Updated 29 Jul 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100