Home Search Member List Faq Register Login  
UltimateSearchMVC
How do I add a search page to my MVC 3 / Razor Website?

Thread Starter: RickB   Started: 11-12-2012 12:49 PM   Replies: 5
 Karamasoft Support Forums » General Discussions » UltimateSearchMVC » How do I add a search page to my MVC 3 / Razor Website?
 Printable Version    Next Thread »
  12 Nov 2012, 12:49 PM
RickB is not online. Last active: 11/13/2012 10:16:45 AM RickB

Top 10 Posts
Joined on 11-12-2012
Posts 5
How do I add a search page to my MVC 3 / Razor Website?
The installation instructions refer "aspx" pages, "controls", "web form" and of course none of those apply to my website.

I need a utility class in which I can pass in a search string from my controller and get back a data structure that I can pass to my razor view ("cshtml") which potentially has a HtmlHelperExtension or a subview to assist in laying out this data.

(and an app that does the indexing)

for example:

SearchController.cs:

public
class SearchController : Controller
{

public ActionResult Index(string id)

{

ViewBag.searchResults = UltimateMVCSearch.search(id);
return
View();

}

Index.cshtml:

@{

Layout = "~/Views/Shared/SiteLayout.cshtml";

}

<h2>Search</h2>

@foreach(UltimateMVCSearchResult r  in ViewBag.searchResults)
{
   @Html.UltimateMVCSearch(r);
}

P.S. How does it handle all of my dynamic database driven pages?  Does it crawl them?  Obviously, reading the cshtml files themselves won't have much content.


  
  12 Nov 2012, 1:25 PM
RickB is not online. Last active: 11/13/2012 10:16:45 AM RickB

Top 10 Posts
Joined on 11-12-2012
Posts 5
Re: How do I add a search page to my MVC 3 / Razor Website?

I found this is SamplesController.cs, but no documentation for the class UltimateSearchOutput?

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult ServerAPI(FormCollection formValues)
        {
            // Get search terms
            string searchTerms = formValues["SearchTextBox1"];

            // Search for the terms
            UltimateSearchOutput ultimateSearchOutput = new UltimateSearchOutput();
            DataView dv = ultimateSearchOutput.Find(searchTerms);
            DataTable dt = dv.Table;

            // Get search results
            string searchResults = "No results found.";
            if (dt.Rows.Count > 0)
            {
                searchResults = "";
                foreach (DataRow dr in dt.Rows)
                {
                    int counter = Convert.ToInt32(dr[0]);
                    string url = dr[1].ToString();
                    string title = dr[2].ToString();
                    string text = dr[3].ToString();
                    int score = Convert.ToInt32(dr[4].ToString());
                    DateTime lastModified = Convert.ToDateTime(dr[5].ToString());

                    searchResults += @"<a href=""" + url + @""">" + title + "</a><br />";
                    searchResults += text + "<br />";
                    searchResults += @"<span style=""color:green"">" + url + "</span><br /><br />";
                }
            }

            // Display search results
            ViewBag.SearchTerms = searchTerms;
            ViewBag.SearchResults = searchResults;

            return View();
        }


  
  12 Nov 2012, 1:40 PM
RickB is not online. Last active: 11/13/2012 10:16:45 AM RickB

Top 10 Posts
Joined on 11-12-2012
Posts 5
Re: How do I add a search page to my MVC 3 / Razor Website?
It seems UltimateSearchOutput is a web control (System.Web.UI.WebControls) so I'm lost.  I'm seeing methods mentioning ViewState etc.  I'm thinking despite having MVC in the name, this search app is for web forms.
  
  12 Nov 2012, 2:42 PM
Karamasoft is not online. Last active: 5/8/2018 10:36:45 AM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,820
Re: How do I add a search page to my MVC 3 / Razor Website?

UltimateSearchOutput is derived from DataList. As you can see in the sample MVC app (Razor) that comes with the installation, you need to use the Find method of the UltimateSearchOutput class if you want to customize your search output by using the Server-Side API methods.

The Find method returns a DataView and you can loop through the collection to display the search output based on your needs as can be seen in the ServerAPI action in the controller.

You can refer to UltimateSearchMVC Control API at http://www.karamasoft.com/UltimateSearchMVC/ControlAPI/index.html.


  
  13 Nov 2012, 9:37 AM
RickB is not online. Last active: 11/13/2012 10:16:45 AM RickB

Top 10 Posts
Joined on 11-12-2012
Posts 5
Re: How do I add a search page to my MVC 3 / Razor Website?

It seems that UltimateSearchOutput might work as an MVC utility class, but I can not point UltimateSearchOutput to UltimateSearch.config.

MVC apps have a predefined directory structure with everything having it's place (and that is important!) so it would be entirely inappropriate to create a subdirectory in the root called UltimateSearchInclude as the *only* directories every going to be there are Content, Scripts, Models, Views, and Controllers.

I could create a separate non-MVC app for the indexing, but that still wouldn't help me with the search pages integrated into the site and thus gains me nothing.

Does Karamasoft do custom programming?  It seems an easy change to provide a new DLL that does not look at ~/UltimateSearchInclude/UltimateSearch.config but instead ~/UltimateSearch.config (which point to a directory outside of the app for the indexing and log file directories).  Note I won't need the css or the js files in this directory as I imagine I'll only ever use UltimateSearchOutput.Find() and UltimateSearchOutput.IndexFull() server side.

I've tried calling Karamasoft for two days and apparently they do not answer their phones.  Is this typical of their support?


  
  13 Nov 2012, 9:51 AM
Karamasoft is not online. Last active: 5/8/2018 10:36:45 AM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,820
Re: How do I add a search page to my MVC 3 / Razor Website?
Unfortunately, we won't be able to create a custom dll for to change the directory structure. Phone support is limited to the active enterprise license customers. Please use email and forums support. Sorry for the inconvenience.
  
 Page 1 of 1 (6 items)
Karamasoft Support Forums » General Discussions » UltimateSearchMVC » How do I add a search page to my MVC 3 / Razor Website?

You can add attachments
You can post new topics
You can reply to topics
You can delete your posts
You can edit your posts
You can create polls
You can vote in polls
Forum statistics are enabled
Forum is unmoderated

© 2002-2018 Karamasoft LLC. All rights reserved.