Click here to Skip to main content
Rate this: bad
good
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
good
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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 304
1 Sergey Alexandrovich Kryukov 295
2 Shweta N Mishra 216
3 Maciej Los 210
4 PIEBALDconsult 184
0 OriginalGriff 7,630
1 Sergey Alexandrovich Kryukov 7,022
2 DamithSL 5,586
3 Manas Bhardwaj 4,946
4 Maciej Los 4,525


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 29 Jul 2013
Copyright © CodeProject, 1999-2014
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