Asp.net gridview link seems to be "expiring" - how to stop?
I have an ASP.NET 3.5 page bound gridview
to a shared list of objects. The purpose of this page is to show the user a list of items they are responsible for, so they can select one and go to the maintenance page to view details about that item.
I have a property AutoGenerateSelectButton
that is True. I have no problem when the user immediately selects one of the elements (by firing at the event .SelectedIndexchanged
, I do a little processing and Response.Redirect
them to the appropriate page).
However, if I wait a few minutes, click Select, I get Can't show the web page as if I were disconnected from the network. Messages are not sent to the application log file (debugging messages that should indicate that the user has selected a specific item and that a redirect will occur), so I have nothing to catch / debug / fix.
I tried to login to web.config and added
"<sessionState timeout="60"></sessionState>"
hoping the timeout would go for an hour (users will often let the app sit on their screens for quite some time), but that didn't seem to work.
Where else can I watch?
a source to share
I had a very similar problem. You may hate this answer because it is a bit tedious, but I have programmatically added a button to the Gridview_RowCreated that allows more power.
On page load, add the column to the grid.
If Not IsPostBack Then
Dim field As New TemplateField
field.HeaderText = "Maintenance"
Dim col As DataControlField = field
GridView.Columns.Add(col)
- Add link here
For i = 0 To GridView.Rows.Count - 1
Dim alinkbutton As New Linkbutton
GridViewCshr.Rows(i).Cells(3).Controls.Add(alinkbutton )
Next
End If
(adding a button to the grid in the third column, but add it if you add a new column programmatically)
--- Then in GridView_rowcommand
Response.Redirect("url")
a source to share
You can see from your web.config file that you are running sessionState in process (default mode). In this mode, session state is effectively persisted in memory by the IIS worker process. This means that when the IIS worker process processing your application exits for example. because IIS recycles the application pool, the session state is erased.
You can increase the workflow downtime (20 minutes by default) in the application pool configuration.
For IIS6
- In IIS Manager, expand Local Computer, Expand Application Pools, right-click the Application Pool, and then click Properties.
- On the Performance tab in the standby timeout, deselect the workflows after the idle to check box. -OR -
- In the minutes box, enter the number of minutes of inactivity (without processing requests) that you want to go through before closing the worker to process. The default is 20 minutes
- Click OK.
For IIS7
- Open inetmgr
- Deploy the appropriate server
- Click "Application Pools"
- Right click on the application pool your application is running in and select Recycle from the context menu
- Deselect all checkboxes, click Next and click Finish
- Right click on the application pool your application is running in and select "More Settings ..." from the context menu.
- In the "Process Model" section, set "Idle Time-Out (minutes)" to some high value
- Click "OK"
However, it would be much better to take session state out of process for long-running applications such as yours. This is a fairly simple procedure and will save you a lot of headaches associated with the session. An article at http://msdn.microsoft.com/en-us/library/ms178586.aspx will give you a good overview on how to do this.
a source to share
Hi David,
Problems like this are hard to solve by asking online, they need to be investigated locally, so I won't give you an answer, just hints:
- Does this application use authentication and authorization? if so, the authentication cookie may expire after leaving the application for a long time and if you click the Select button you will be taken to the login page, but the login page itself may have an issue that causes most browsers to display the message "This page is not may display "after several cycle runs. This loop can be caused by other factors, so I suggest tracking your http interactions with Fiddler , you will know what the server is responding and why the browser is displaying an error page.
- When attaching the fiddler, I suggest running the application in debug mode, and in the visual studio menu, choose Debug> Exceptions, then check all the boxes in the Thrown and Custom Unhandled columns, this will cause the debugger to break every exception even if they are processed.
- The last point is irrelevant: I suggest changing the way users are selected from the grid. instead of a "select" link, place a link with the URL of another page and pass the ID of the selected item as a URL parameter. This will save you server travel and tiny storage overhead. On another page, you have to take care that someone is not playing with the url parameter in order to manipulate data that they do not have permission to manipulate.
a source to share