Branislav Abadjimarinov's technical blog

Branislav Abadjimarinov's technical blog

  1. Visual Studio debugging and IIS 7 Application pools problem

    I had a strange problem debugging asp.net websites hosted on IIS 7. I attached the Visual Studio debugger to the working process of the IIS (in my case w3wp.exe) and started debugging. After a couple of minutes I got disconnected. This behavior reproduced every time.
    After checking the IIS 7 Application pool settings I found out that this is an intended behavior. The IIS pings the working process in a configured time intervals (2 minutes by default) and if the process is hanging (not responding)  it restarts the process. When you attach a debugger to the process and you stop at a breakpoint for more than 2 minutes the process will not respond to the ping and it will be killed in the middle of your debugging session. To prevent this simply disable ping in IIS Application Pool settings or extend the ping time intervals.If you do this in development environment don't forget to switch it to true on production servers, because it may be a security issue.


    To switch it off:
    1. Open the IIS Manager (Run->inetmgr).
    2. Go to the "Application Pools" and select your site's pool.
    3.In the right pane click Advanced Settings.
    4.Find "Ping Enabled" in the list of settings and choose "False" for its value


    How to disable IIS 7 Application pool ping

    Posted by Branislav Abadjimarinov on November 12 at 6:36 AM

  2. Course Programming .NET and WPF

    This semester at FMI, Sofia University, is starting a new course dedicated to programming  .NET and using the latest Microsoft  technologies. The course is called "Programming .NET and WPF".  You can check out the program of the course on the official site of FMI. The course also has an online home - www.dotnet.graduate-bg.com , where you can check the schedule of the lectures, download the presentations or ask questions in the forum . The course will present the newest and most powerful presentation technology from Microsoft - WPF (Windows Presentation Foundation). I'll do some basic lectures on Attributes and Strings and also some more in depth presentation on LINQ and multi-threaded programming techniques. This course continues the fine tradition not only to show the latest technologies but also to give students a chance to play and develop their own projects as part of the curriculum.

    Posted by Branislav Abadjimarinov on October 28 at 2:53 PM

  3. How to render asp.net control to string

    Every control in ASP.NET inherits from System.Web.UI.Control and have the RenderControl method. When you want to get the html output of the control at any point of the page execution lifecycle you can use the following method.

    public string RenderControl(Control ctrl)
    {
        StringBuilder sb = new StringBuilder();
        StringWriter tw = new StringWriter(sb);
        HtmlTextWriter hw = new HtmlTextWriter(tw);

        ctrl.RenderControl(hw);
        return sb.ToString();
    }

    At this point ASP.NET MVC does not have full support for asp.net controls. Using this trick you can render control's html directly on the view using a html helper. While this is good for read-only controls it will not work with controls that require event handling because in ASP.NET MVC by default you are missing  the page lifecycle.

    Posted by Branislav Abadjimarinov on October 28 at 9:10 AM

  4. ASP.NET MVC default route problem

    If you are working with ASP.NET MVC you definitely have seen that in the startup project in Visual Studio in Global.asax file there is a default route added like this:

    routes.MapRoute(
    "Content",     // Route name
    "{controller}/{action}/{id}",    // URL with parameters
    new { controller = "Home", action = "Index", id = "" } // Parameter defaults
    );

    It is very useful to quickly show how the MVC works but in commercial projects I'll suggest  not to use a default route for handling /{Controller}/{Action} requests in ASP.NET MVC. By doing that you can get a ton of these exceptions:

    System.Web.HttpException: The controller for path '/MyCustomPath/' could not be found or it does not implement IController.

    The reason for this is that when you make a request for non-existing path like /MyCustomPath/ the MVC Controller factory will try to instantiate a class inheriting IController and named "MyCustomPath" and when It doesn't find it an exception will be thrown.
    If the non-existing url is in some static file like .css or .js or the html of the page you can get a lot of these exceptions in just a few seconds if the web server is under a heavy load.

    The solution is simple - just remove the default route and add explicitly routes with the controllers you actually use. By doing that you'll get a 404 without the exception.

    Posted by Branislav Abadjimarinov on October 26 at 1:09 PM

  5. Intro post

    Big Hi to all who are reading this. This is the first "post" (more like a welcoming message) in my newly created blog. I've been in the IT and programming business for some time by now but I've never had the idea of starting a professional blog. There are three main reasons for this. First, I'm more like a "suffer in silence" type. Second, I wanted to gain some more experience before speaking as an authority on professional subjects. And last when I started I thought that the last thing the world (wide web) needs is another blog on technical stuff. But things change and so does my opinion. With the years I've started to trust in the community and finally decided to create what you're reading at the moment.

    To cut the long story short - this blog will be mainly (if not fully) dedicated to my professional interests, namely - programming, software architecture, Microsoft and open source technologies and applied science (artificial intelligence mainly).

    Posted by Branislav Abadjimarinov on October 19 at 6:08 AM

© Copyright 2017 Powered by AtomSite 1.3.0.0