Blog posts by Branislav Abadjimarinov2009-11-12T13:36:00.0000000Z/blogs/Branislav-Abadjimarinov/Optimizely WorldVisual Studio debugging and IIS 7 Application pools problemhttp://abadjimarinov.net/blog/2009/11/12/VS_debugging_and_IIS_App_pools_problem.atom2009-11-12T13:36:00.0000000Z<div xmlns="http://www.w3.org/1999/xhtml"><p>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.<br />
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.</p><p><br />
To switch it off:<br />
1. Open the IIS Manager (Run->inetmgr).<br />
2. Go to the "Application Pools" and select your site's
pool.<br />
3.In the right pane click Advanced Settings.<br />
4.Find "Ping Enabled" in the list of settings and choose "False"
for its value</p><p><br /><a href="/img/media/How to disable IIS 7 Application pool ping.png"><img alt="How to disable IIS 7 Application pool ping" src="/img/media/How to disable IIS 7 Application pool ping.png" style="width: 30em; height: 20em" /></a></p></div>Course Programming .NET and WPFhttp://abadjimarinov.net/blog/2009/10/28/CourseProgrammingDotNETAndWPF.atom2009-10-28T20:53:00.0000000Z<div xmlns="http://www.w3.org/1999/xhtml"><p>
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 <a href="http://www.fmi.uni-sofia.bg/education/bachelors/izborni_0910_zimen/Programirane%20s%20.NET.pdf">site of FMI</a>. The course also has an online home - <a href="http://www.dotnet.graduate-bg.com">www.dotnet.graduate-bg.com</a> , 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.</p></div>How to render asp.net control to stringhttp://abadjimarinov.net/blog/2009/10/29/HowToRenderAspdotNETControlToString.atom2009-10-28T15:10:00.0000000Z<div xmlns="http://www.w3.org/1999/xhtml"><p>
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.</p><p>
public string RenderControl(Control ctrl) <br />
{<br />
StringBuilder sb = new StringBuilder();<br />
StringWriter tw = new StringWriter(sb);<br />
HtmlTextWriter hw = new HtmlTextWriter(tw);</p><p>
ctrl.RenderControl(hw);<br />
return sb.ToString();<br />
}</p><p>
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.</p></div>ASP.NET MVC default route problemhttp://abadjimarinov.net/blog/2009/10/27/AspdotNETMvcDefaultRouteProblem.atom2009-10-26T19:09:00.0000000Z<div xmlns="http://www.w3.org/1999/xhtml"><p>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:</p><p>routes.MapRoute(<br />
"Content", // Route name<br />
"{controller}/{action}/{id}", // URL with parameters<br />
new { controller = "Home", action = "Index", id = "" } //
Parameter defaults<br />
);</p><p>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:</p><p>System.Web.HttpException: The controller for path
'/MyCustomPath/' could not be found or it does not implement
IController.</p><p>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.<br />
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.</p><p>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.</p></div>Intro posthttp://abadjimarinov.net/blog/2009/10/19/Intro.atom2009-10-19T13:08:00.0000000Z<div xmlns="http://www.w3.org/1999/xhtml"><p>
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.<br /><br />
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).</p></div>