ASP.Net and the Confusion of GET and POST

By Deane Barker on October 17, 2007

My loathing for ASP.Net has been well-known in these pages, but part of me has made peace with it. There are some things about ASP.Net that I very much like, and I promise I’ll post about them one day.

Today ain’t that day.

I will never accept the stupidity of the server-side FORM tag and the confusion of GET and POST. Never. It drives me nuts – ASP.Net encourages you to POST everything, and that’s just not right. It’s not the intention of the HTTP spec, and it kills usability in a lot of situations.

Case in point – the Applebees menu system displayed above.

I’m having a lunch meeting at my office today for my church IT committee. We have an Applebees on the next block, and I wanted to email everyone a link to the menu for this restaurant. But I can’t.

Problem is, the developer who built their site used a DataGrid control to display the restaurant listings, and he bound the link buttons in it to server-side events. So those buttons in the picture are actual form buttons which POST data, not simple hyperlinks that link to an “email-able” URL. So when I click the buttons, I get a generic URL that’s useless without POST data...which I can’t send in an email.

Here’s the URL:

If you click that, it will just loop back to the search form (unless you’ve been there before, because it appears to save your last restaurant as a cookie or session value).

The thing is, I know to check this. I know to look in the URL and make sure it’s valid on its own. But how many other people do? I wonder how many people every single day email that URL to someone and get a response like, “That URL you sent didn’t work for me...”

Why, oh why, do people do this? Oh yeah, because ASP.Net encourages you to do it.

(Sad thing is, making this particular situation GET-friendly wouldn’t have been much more difficult. It appears to be a cross-page postback anyway, so how hard would it have been to have just put the menu ID in the querystring and make the link an actual hyperlink? It’s not like it’s posting back to itself.)

Yes, I know, other languages encourage you to do stupid things too, however they’re usually confined to server-side and code-centric stupidity which doesn’t affect the user so much. The difference here is that ASP.Net infiltrates the client way too damn much, and stuff like this results.

Comments (5)

Matt Smith says:

Hopefully help is on the way – Microsoft is building support into ASP.NET for a (real) model-view-controller (MVC) architecture.

There were bits and pieces available about the topic several months ago, but two weekends ago there was an ALT.NET Conference in Austin where Scott Guthrie presented their current MVC functionality.

From Scott Guthrie’s post:

“The MVC framework supports using the existing ASP.NET .ASPX, .ASCX, and .Master markup files as “view templates” (meaning you can easily use existing ASP.NET features like nested master pages, snippets, declarative server controls, templates, data-binding, localization, etc). It does not, however, use the existing post-back model for interactions back to the server. Instead, you’ll route all end-user interactions to a Controller class instead – which helps ensure clean separation of concerns and testability (it also means no viewstate or page lifecycle with MVC based views).”

Read more about it:

Be sure to check out the presentations linked from Scott Hanselman’s site.


Liming Xu says:

I agree ASP.NET encourages people to make bad choices.. but I stillI think it’s more of an requirement issue. If AppleBee developers knew about people are looking for this functionality, they could easily replace it with a hyperlink. LIke you said, it’s not hard, they simply just never thought of this requirement.

We ran into the same issue before where our marketing director wants links on our website to be search engine friendly. So we had to get rid of the post backs and replaced them with the traditional links.

For .NET developers, I think the point is this. To know what to use and when to use them. ASP.NET offers way too many choices for people and it created the paradox of choices. I like post backs and viewstate. They solved many issues for me, but if we abuse them or use them in the wrong places, then it creates problems too.

Deane says:

If AppleBee developers knew about people are looking for this functionality, they could easily replace it with a hyperlink. LIke you said, it’s not hard, they simply just never thought of this requirement.

Two points here.


This is a pretty simple requirement, so it’s sad they never thought of this.


ASP.Net encouraged them to do this. There is about a 1% chance they would have architected it this way if they had been using another platform.

dave says:

I’m seeing this in some code I’m updating, and it bugs the hell out of me. I’m always seeing things like postbacks that just do redirects. Because ASP takes care of this for you, and makes posting easy, people use postbacks for everything. Not every webpage is an “application”, and ASP encourages people to overcomplicate things.

I’ve come to the conclusion that most ASP developers have no idea what’s going on behind the scenes, and so they don’t understand how to do things properly. I’ve looked for a decent tutorial on asp, but most of what I find are simple little examples, and not a good explanation of the architecture. I think most ASP programmers just put together little fragments of code, without a clue about how the different parts work together. I’ve worked on a lot of other people’s code, and ASP programmers are by far the worst. It’s a shame too, because there are a lot of good ideas behind, but MS implements it in such a way that encourages people to use bad practices, and unnecessarily complicates simple tasks.

Effective Publishing: Findable, Usable, Actionable | Content Here says:

[...] compound pages (like a portal or an application) can make this complicated. Don’t make the Applebees mistake. A share link builder is useful here. This link better not require a registration form or login. [...]