0

i have a form that have a field which hold query for search and a button to send query value to another action method to perform search. now i want to send this parameter as querystring; not form parameter. but when i click on submit button it's value isn't shown on address bar and sended as form parameter.

<% using (Html.BeginForm("Result", "Search", FormMethod.Post))
       { %>
    <input id="query" name="query" type="text" value="<%: ViewData["InitialQuery"]%>"
        class="search-field" />
    <input id="search" type="submit" value="Search" class="search-button" />
    <%} %>

public ActionResult Result(string query)
    {
        if (string.IsNullOrEmpty(query))
            return RedirectToRoute("SearchEngineBasicSearch");
        var search = new Search();
        var results = search.PerformSearch(query);
        if (results != null && results.Count() > 0)
            return View("Result");
        return View("Not-Found");
    }

URL after clicking on submit button is .../search/result and i want to be .../search/result?query=someQueries

thank in advance ;)

1 Answer 1

3

Change FormMethod.Post to FormMethod.Get.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.