Link to home
Create AccountLog in
Avatar of Webbo_1980
Webbo_1980

asked on

how can i run a long job in asp.net without the browser timing out

I’m looking to perform a long and time consuming job via asp.net e.g. lets say a 10min job. This job is simply going to cycle through 1000 items and do a thread sleep for 1 second per row. Now my question is obviouls this is just a example so using this how can I display to the user what the current row is and stop .net from timing out. Any demos / sample code would be greatly appreciated

Thanks
Webbo
Avatar of tiagosalgado
tiagosalgado
Flag of Portugal image

Add this to your web.config

<location path="somefile.aspx">
	<system.web>
		<httpRuntime executionTimeout="180"/>
	</system.web>
</location>

Open in new window

Avatar of Webbo_1980
Webbo_1980

ASKER

thanks but my question was more relating to a code examples of how i display this to the user?

Doing this yes will stop the time out, but the screen will just hang until the job wa s done
You can use ASP.NET AJAX. Add an updatepanel with a updateProgress to display a message to user.


<asp:UpdatePanel runat="server" id="up1" UpdateMode="Conditional">
<ContentTemplate>
your code appears here!!!

 <asp:UpdateProgress runat="server" ID="updateProgress1" AssociatedUpdatePanelID="up1" DisplayAfter="0">
<ProgressTemplate>
<div>my code is executing...please wait!</div>
</ProgressTemplate>
</asp:UpdateProgress>
</ContentTemplate>
</UpdatePanel>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of tiagosalgado
tiagosalgado
Flag of Portugal image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account