Gursharn Singh
Gursharn Singh

Reputation: 75

Implementing long running search in ASP.NET

I am building a search page in asp.net 3.5. Search takes a bit of time (few seconds to few minutes). Current I use AsyncMethodCaller to call Search method. AsyncMethodCaller method stores search results in Session. I user Ajax timer to check if Search method finished and then display results.

What would be the best way to implement this scenario?

Upvotes: 1

Views: 160

Answers (3)

gsharp
gsharp

Reputation: 27937

I would use a Page Method from the ASP.NET Ajax Framework. It's easy to call them async and you have a callback when it's done.

Have a look here. (Async is explained at the commens of the post)

Upvotes: 1

Dave Archer
Dave Archer

Reputation: 3060

You could try the reactive extensions for .NET . I haven't tried them yet, but looks promising.

Upvotes: 1

Andy Shellam
Andy Shellam

Reputation: 15535

That seems perfectly fine to me, or have I missed the point of the question?

I did a similar thing recently in a PHP front-end with a search that takes about 30 seconds.

I implemented the actual search logic as a console application. The web service calls the console application to carry out the search and records the process ID of the application handling the search in the session.

An AJAX timer in the front-end polls the server every second, which checks if that process ID is still running. If it's finished, it looks in the database (where the application writes the results) and sends those back to the front-end.

If Javascript is disabled, a simple meta refresh does the same thing.

Upvotes: 0

Related Questions