Click here to Skip to main content
11,806,818 members (57,055 online)
Rate this: bad
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 10: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
0 ppolymorphe 245
1 OriginalGriff 150
2 George Jonsson 145
3 CPallini 100
4 Abhinav S 80
0 OriginalGriff 3,380
1 Maciej Los 1,990
2 CPallini 1,915
3 KrunalRohit 1,907
4 ppolymorphe 1,317

Advertise | Privacy | Mobile
Web01 | 2.8.151002.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