# CodeSOD: Session Recording

DevFeed: [CodeSOD: Session Recording](<https://devfeed.tech/articles/codesod-session-recording-105625.md>)

Original publisher: [Read original article](<https://thedailywtf.com/articles/session-recording>)

Author: Remy Porter

Published: 2026-10-28T06:30:00Z

Content type: article

Language: en

Sources: [The Daily WTF](<https://devfeed.tech/sources/the-daily-wtf.md>)

Topics: [ASP.NET](<https://devfeed.tech/topics/aspnet.md>), [sql-database](<https://devfeed.tech/topics/sql-database.md>), [sessions](<https://devfeed.tech/topics/sessions.md>)

Tags: [asp-net](<https://devfeed.tech/tags/asp-net.md>), [autocomplete](<https://devfeed.tech/tags/autocomplete.md>), [codesod](<https://devfeed.tech/tags/codesod.md>), [database](<https://devfeed.tech/tags/database.md>), [redirect](<https://devfeed.tech/tags/redirect.md>), [sql-injection](<https://devfeed.tech/tags/sql-injection.md>)

## AI overview

The Web Forms snippet reads an album ID from a control, stores it in session, builds and executes a SQL DELETE query using that ID and the session user ID, then redirects. The author criticizes the indirect FindControl-to-Label lookup, using a label to hold input, and the concatenated query as vulnerable to SQL injection. They also question storing the query in a page member and criticize broad use of session state, including for form inputs and loop variables. The redirect's HTTP 300 navigation and the "frm" prefix in the destination URL are additional complaints.

## Source excerpt

We still get a fair bit of old school ASP .Net webforms code, which was cutting edge about twenty years ago, but remains a collection of bad choices that tried to make web programming feel like desktop programming. As an aside, what a reversed world we live in today, where everyone uses Electron and our desktop programming feels like web programming. In any case, Thomas sends us some pretty ugly webforms code. Me.Session("Albumid") = CType(e.Item.FindControl("lblAlbumID"), Label).Text If Not Me.Session("Albumid") Is Nothing And Not Me.Session("Uid") Is Nothing Then Me.strDelSQL = "Delete from tbl_Albumshare_Mast where Album_Id=" & Me.Session("Albumid") & " and Sharer_ID=" & Me.Session("Uid") Me.objDB.ExecQry(Me.strDelSQL) Me.Response.Redirect("frmmyalbumshare.aspx", False) End If Broadly, the goal of this code is to take an album ID from the user and delete an album from the database where the ID matches and the album is owned by this user. And everything is horrible here. First, the use of e.Item.FindControl to look up the input field is suspicious. That's usually what you do when you've dynamically generated controls, but I don't think that's happening here. Because we use FindControl we have to cast it to Label, and only then can we get the text property. That itself raises a question, because why are user inputs getting stored in a label?. That's not what labels are for. They're clearly doing some sort of hacky lookup/autocomplete field thing and using the label to actually store the input, but presenting the user with a different UI for picking it. Not an uncommon pattern in those days, but a hidden field would be a more typical way of doing it. We then construct a SQL injection vulnerability and run it against the database. Then, we use a redirect to send the user to a different page. Again, a common thing to do back then, but a thing I hate: using HTTP 300 codes to redirect users as a form of navigation is awkward and weird. Of course, none of that is precise