Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Gayathri 55 posts 175 karma points
    Jun 25, 2018 @ 03:09
    Gayathri
    0

    Umbraco searchresult leads 404 page instead Search Result Page

    When using the search form getting a list of results it goes to 404 Page not found instead search Results page.

    the Search Results.cshtml is

    <form action="/searchresult/" method="GET">
            <input type="text" class="searchfield" placeholder="" name="query">
            <button class="searchbtn btn btn-default btn-sm">Search</button>
        </form>
    
         @{
            var searchQuery = Request.QueryString["query"];
    
            if (!string.IsNullOrEmpty(searchQuery))    
            {
                <div class="searchresults">
                    <p class="intro-para">Your search results for <strong>"@searchQuery"</strong></p>
                    <ul>
                        @foreach (var result in Umbraco.Search(searchQuery))
                        {
    
                            <li>
    
                                <a class="heading1 inline-link" href="@result.Url">@result.Name</a>
                                <div  class="heading2">Created Date : @result.CreateDate.ToLongDateString()</div>
                                <div  class="heading2">Updated Date : @result.updateDate.ToLongDateString()</div>
                            </li>
                        }
                    </ul>
                </div>
             }
        } 
    

    http://gmohan:8018/searchresult/?query=loan

    enter image description here

    Has anyone else run into this error and found a way to fix it?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jun 25, 2018 @ 05:37
    Jan Skovgaard
    0

    Hi Gayathri

    Do you have a published page in the backoffice that is named "searchresult"? Sorry if this seems like a silly question but I'm guessing that either the page is not published, or does not exist or perhaps there is a spelling mistake either in the nodename or in your code, which is why you hit the 404 page instead? :)

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft