Model binding in ASP.NET MVC can be fun

Model binding is a technique that allows you to map data to your controller actions in ASP.NET MVC. In the old days one would manually call Request["param"] to get the value of а parameter, but this could quickly become annoying as you get many parameters (f.x., via form POST). Model binding abstracts away this tedious activity and allows us to focus on designing our controllers. The process itself looks like this:

Model binding mechanism

A nice bonus is that we can map our models from any kind of request, for example a form POST or AJAX. Continue Reading…

HttpWebRequest keeps timing out

It has already happened to me a couple of times and every time I forget what the issue was and how to solve it. That’s why I decided to write a short post about it, so hopefully next time I will remember. 🙂 The problem arises when making a few (independent) HTTP requests using C#’s HttpWebRequest. At first it sounds like a very usual thing to do, but the mystical part of it is that the first few requests succeed and then at a certain point the others start timing out. You may be tempted to increase the Timeout first, but you will soon understand that it does not solve the problem. Continue Reading…

Integrate external web services with slow responses

Sad userRecently I have been working on a project, which involved communication with a lot of external systems. These systems were mainly web services and databases. During the development phase of the project I only had access to a test version of these systems, i.e. dealing with test data. One of these external systems was of a greater interest as it was designed to serve the main data the customer dealed with. It was a traditional SOAP web service (build on ASP.NET). The service contains a bunch of methods to retrieve and update data. Everything seems pretty normal so far. However, a few of these methods that fetch data happened to work very slow. By working slow I mean, that the external server took its time to do the necessary computations. The calls to these methods were sometimes so slow that users had to see a waiting screen for 10 minutes. And this is pretty annoying. And the customer realized it. The first solution was, of course, to ask the customer if it was possible to optimize this service. Unfortunately, the service itself is developed and maintained by another company and it could take some time until a better version was released. We didn’t have this time, so we had to work ourselves on this issue. Continue Reading…

protected internal exposed

.NET gives developers a lot of freedom. In every version new features are added to ease them in their daily work. One of the simplest things that have existed since the first versions of .NET framework are access modifiers. Using them one sets the access to a specific class/method. Public, private, protected… all are standard modifiers. If you have experience with an object-oriented language you must know them by heart. .NET provides another modifier – internal. It allows access to a method only in the parent assembly (the one the corresponding class resides in). Continue Reading…