Wednesday, 8 September 2010

MVC custom error problem on IIS7



From bitter experience I have now learned (once again) how important it is to test your applications in a staging environment which is different from your development machine.

In this case our problem was customErrors, which looks fantastic on your developer machine, but gets thrown away when you install your application in the IIS 7 server.

Luckily I found this guys post:
IIS 7 Error Pages taking over 500 Errors which describes the problem. Only when you use MVC and do some error handling in the controllers, it doesnt arrive to the Application_Error method, as he describes, but instead you should add the "TrySkipIisCustomErrors" in the OnException in each controller.

protected override void OnException(ExceptionContext filterContext)
{
string viewName = "MyErrorView";
System.Web.HttpContext.Current.Response.TrySkipIisCustomErrors = true;
View(viewName, errorData).ExecuteResult(this.ControllerContext);

}

In any case its always good to do something in the Application_Error method, if nothing else, log any errors which is not handled any other places

Wednesday, 30 June 2010

71-515 .NET 4 web application developer

Finaly Microsoft gave me my result of my Beta exam:



I PASSED :D

Visual Studio 2010 cheat sheet

I found the cheat sheet for VS2010: link

Friday, 4 June 2010

adding dates to a filename in a bat script

In case others out there need something so prehistoric as making a bat script which adds a date to a filename for ex when creating a back up with 7-zip.

The following worked for me:

call "c:\Program Files\7-Zip\7z.exe" a -tzip %date:~6,4%-%date:~3,2%-%date:~0,2%.%time:~0,2%-%time:~3,2%-zipFile.zip *.dll


will zip files into an archive called:


2010-06-04.15-37-zipFile.zip


Hope it will save you some frustration!

Thursday, 4 March 2010

Prealoading Web Applications

On the list of what's new in ASP.NET 4.0 you find "Prealoading Web Applications".

If you are running ASP.NET 4.0 on IIS 7.5 you can ask sites to be preloaded when the Internet server starts up (or restarts).

It sounds cool, and a good thing that you are now able to reload heavy services, but I can help thinking that it is also a solution to a problem which should exist. The IIS should handle the Internet communication, while leaving the heavy data processing to services outside of the IIS. These services would should be implemented as services on the server, No?

70-515. TS: Web Applications Development with Microsoft .NET Framework 4

With the announcement of the .NET 4.0 exams, it seems a bit like a wrong career move not to aim for taking the web application development certificate for 4.0 instead of 3.5, since I have already been working with VS2010 for some time now.

Looking at the Skills Being Measured List it seems like a good idea to continue studying the MCTS Self-Paced Training Kit (Exam 70-562) with a sharp eye to the list of topics.

Hopefully I will be invited to take a beta exam when they come out in April.

I guess a good place to start looking into the ASP.NET 4.0 would be here

Here are some of my comments to the elements of What's new:

Tuesday, 9 February 2010

ExecuteScalar doesn't return the return value

One thing to remember when making a stored procedure or just simple SQL, which should be executed thought a call of the ExecuteScalar method in .NET: that ExecuteScalar doesn't actually return the return value but the first column of the first row in the result set, or a null reference if no result is found!