Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4323680
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:02:01+00:00 2026-05-21T09:02:01+00:00

I am trying to use Async controller and am not able to figure out

  • 0

I am trying to use Async controller and am not able to figure out how would one validate the user input.

Following are the two async methods defined in my controller. Should I check for ModelState.IsValid in the SearchAsync method or SearchCompleted method. If SearchAsync then how will return the view result as its return type is void. If SearchCompleted then how will the method know about searchForm parameter.

[HttpPost]
[ValidateAntiForgeryToken]
public void SearchAsync(BusinessSearchForm searchForm)
{
    AsyncManager.OutstandingOperations.Increment();
    new Thread(() =>
    {
        var suggestions = _searchSvc.GetSuggestions(searchForm.BusinessName, searchForm.StreetAddress, searchForm.City, searchForm.PostalCode);
        AsyncManager.Parameters["suggestions"] = suggestions;                   
        AsyncManager.OutstandingOperations.Decrement();
    }).Start();
}

public ActionResult SearchCompleted(IEnumerable<BusinessSuggestionBase> suggestions)
{
    return View(suggestions);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T09:02:02+00:00Added an answer on May 21, 2026 at 9:02 am

    The following seems to work for me. I end up checking for modelstate in both methods. Added the initial model as a param to the completed method. Asp.net Mvc seemed to persist the modelstate between the two methods

        [HttpPost]
        [ValidateAntiForgeryToken]
        public void SearchAsync(BusinessSearchForm searchForm)
        {
            if (ModelState.IsValid)
            {
                AsyncManager.OutstandingOperations.Increment();
                new Thread(() =>
                {
                    if (ModelState.IsValid)
                    {
                        var suggestions = _searchBusinessSvc.GetSuggestions(searchForm.BusinessName, searchForm.StreetAddress, searchForm.City, searchForm.PostalCode);
                        AsyncManager.Parameters["suggestions"] = suggestions;
                    }
                    AsyncManager.Parameters["searchForm"] = searchForm;
                    AsyncManager.OutstandingOperations.Decrement();
                }).Start();             
            }
        }
    
        public ActionResult SearchCompleted(BusinessSearchForm searchForm,IEnumerable<BusinessSuggestionBase> suggestions)
        {
            if (ModelState.IsValid)
            {
                TempData["suggestions"] = suggestions;
                return RedirectToAction("SearchResult");
            }
            return View(searchForm);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to figure out what the best way to approach Async object
I'm trying to use SQLBindParameter to prepare my driver for input via SQLPutData .
I'm trying to use async workflows in F# to fetch several web requests. However,
I'm trying to use async from the asp.net mvc futures, using my own async
I'm trying to use async io on linux. As far as i know there're
I'm trying to use the Stream.BeginWrite Async I/O API in .NET for a high-throughput
I am trying to use the code from Microsoft for an Async Socket connection.
I'm trying to use the async HttpWebRequest in Silverlight for Windows Phone. All works
I'm trying to use the Async CTP, while it appears to install correctly neither
I'm trying to read a XML-RSS-Feed from a website. Therefore I use a async

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.