Debugging is the process of finding and resolving defects or problems within the program that prevent correct operation of computer software or a system. Debugging tactics can involve interactive debugging, control flow analysis, unit testing, integration testing, log file analysis, monitoring at the application or system level, memory dumps, and profiling.
Some bugs may be easy to track. I don't want to talk about those. Let's discuss the really mysterious ones.
Like the saying goes, Theory is when one knows everything but nothing works; Practice is when everything works but nobody knows why. Sometimes Theory and Practice go hand in hand: nothing works and nobody knows why. In such cases, it's worth remembering about some effective techniques that often allow us to reach the root of the problem and to display its finer details. Over time, here are the 3 techniques that have been most useful when debugging with Visual Studio:...
Read more
In ASP.NET MVC, we manipulate Views, among other things. Some of these Views represent full pages and some are just page parts. These parts or areas belonging to a view are called partial views, and they are also returned by controller actions. Since these partial views should only be used within a view, the ASP.NET MVC framework allows us to protect any call to these partial actions by decorating them with the ChildActionOnly attribute. This attribute makes sure that the action:
- cannot be used as an entire view and the application developers will always run it using the HtmHelper.Action or HtmlHelper.RenderAction methods.
- has a URL that will not be accessible via the address bar, if a user somehow becomes aware of the existence of this URL.
However, as with any dynamic site, we will have AJAX requests that can also make requests for HTML content without having to load the page completely. This content also represents a part, and when we receive the response from the web server we have to embed this piece of HTML somewhere in the page. The AJAX request sent to the server will certainly invoke a controller action. This action, like those marked with the ChildActionOnly attribute, must have these constraints:
- should only go through AJAX requests.
- inaccessible via the browser address bar.
But the ASP.NET MVC framework does not offer any attributes that allow us to apply these restrictions to an action, but it gives us the tools to create them....
Read more
I recently answered a question that came up on the StackOverflow website. The question was whether using the ViewBag dynamic property of the controller to expose the error message was a good practice, as the OP investigations suggested that it was necessary to expose properties from the model.
Obviously it is highly recommended NOT to use the ViewBag property since it does not provide any Strong Typing. If you want to communicate with the view you should always involve a typed model. The suggested solution is therefore legitimate in that respect, however, it is not a good practice when it comes to model error handling in ASP.NET MVC.
The solution for exposing error messages (as in the previous example, which does not use data annotation attributes) derives from the use of the AddModelError method, from the ModelStateDictionary class. We do not need to instantiate this class because a ModelState property containing an instance of this class already exists in the Controller.
Therefore, the right solution is the following:...
Read more
I started programming when I was in high school. I learned a few lessons over the past decade, and I thought I would take a moment to gather my thoughts on these things. It took me about ten years and a lot of experimentation to figure out some of this....
Read more
If you don't know what Xamarin is, may I suggest that you start by reading my introductory notes before proceeding with this ? For those in the now, let's get into it without further ado....
Read more
Xamarin is a cross-platform development tool. It solves dilemmas many developers face when developing cross-platform apps: separate coding languages and UI paradigms. With Xamarin, you can use C# for iOS, Android, and Universal Windows apps. And with Xamarin Forms, interface design for all three platforms can be accomplished within its XAML-based framework. Here is some documentation I would recommend if you consider getting started with Xamarin....
Read more
Pluralsight is the largest online tech and creative library on the planet.
An online education platform that offers a variety of video training courses for software developers, IT administrators, and creative professionals through its website.
I have been learning quite a bit from Pluralsight, and here are my favorites so far....
Read more
C# (C Sharp) is Microsoft flagship programming language, hence its popularity in the tech industry. Used by a large and growing number of professionals, it helps when building all kinds of applications. A frequently asked question is, where do I start with C#, what are the best free courses ?...
Read more
The Entity Framework is an ORM system, a set of technologies that support the development of data-oriented software applications. It's part of the .NET Framework. I have been playing with it for a couple of years and here are my top tips :...
Read more
A fresher sent me the following query:
Hi Necemon, thank you for accepting my invite. I am new to the IT field and I would appreciate if you could give me some guidance. Based on your work experience, can you tell me what companies look for in a computer guy ?
I have heard about you from senior students at Christ University, I am in Bangalore and I like computer science but I do not know what to learn and how to begin.
Actually, I think I like programming but I am told that the C language is no longer relevant, and I am also told about Ruby, C #, Python, etc. I'm confused....
Read more