The 404 page in web.config

by edward.lategan October 19, 2009 11:30

What is a 404 page? According to Wikipedia the 404 page is a HTTP standard response code indicating that the client was able to communicate with the server but the server could not find what was requested. This could be a static page like "aboutme.aspx" or a dynamic content page like "default.aspx?page=phoenixcode".

In ASP.NET you have the option to create your own 404 page, and redirect the user to this page if the page does not exist, and not display an ugly error to the user.

If you would configured custom 404 page in web.config file in the "customErrors" section, this will tell the server to serve your 404 page, instead of showing an ugly message to the user.

   1:  <customErrors defaultRedirect="ErrorPage.aspx" mode="On">   
   2:      <error statusCode="404" redirect="404.aspx" />
   3:  </customErrors>


The code snippet above will send all users to a "ErrorPage.aspx" page if there is an error in the application, but if there is a 404 error, the user will be redirected to "404.aspx" instead.

You also don't need to parse the customErrors section to get name of the custom 404 page. Just throw HttpException:

   1:  throw new HttpException(404, "Article not found");
   
ASP.NET run-time will catch the exception and will redirect to the custom 404 page.

Tags: , , ,

C# | General

Firebug

by Jacobus Meintjes June 02, 2009 16:35

A very nice Firefox add-on to assist with web development

As sourced from the site.

Firebug integrates with Firefox to put a wealth of web development tools at your fingertips while you browse. You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page.

 

Firebug

Tags: , , ,

General

NHibernate error - "Incorrect syntax near the keyword 'User'."

by Jacobus Meintjes April 20, 2009 14:26

If you ever experience this while using NHibernate, just do the following:

1. Open the mappings file, in my case User.hbm.xml and go to the following line of code

<class name="Model.UserEntity, Model" table="User">

The SQL generated for this class is

SELECT this_.GUID as GUID8_0_, this_.IsDisabled as IsDisabled8_0_, this_.LoginName as LoginName8_0_, this_.Name as Name8_0_ FROM User this_

 

2. Change the table that the class is mapped to, to the following

<class name="Bookstore.Model.UserEntity, Bookstore.Model" table="[User]">

The new SQL will look something like this

SELECT this_.GUID as GUID8_0_, this_.IsDisabled as IsDisabled8_0_, this_.LoginName as LoginName8_0_, this_.Name as Name8_0_ FROM [User] this_

 

The reason for this is, User is a reserved word in SQL Server. Escape it with hard brackets, [ ]. User is the name of a security function that returns the current user's database username in SQL. Typically it will return 'dbo'.

Tags:

General | NHibernate

What's the difference between C, C++ and C#

by Jacobus Meintjes April 01, 2009 22:53

The facts

C - an older programming language that is described as Hands-on. As the programmer you must tell the program to do everything. Also this language will let you do almost anything. It does not support object orriented code. Thus no classes.

C++ - an extention language per se of C. In C code ++ means increment 1. Thus C++ is better than C. It allows for highly controlled object orriented code. Once again a very hands on language that goes into MUCH detail.

C# - Full object orriented code resembling the style of C/C++ code. This is really closer to JAVA. C# is the latest version of the C style languages and is very good for developing web applications.

My opinion

Coming from a C/C++ background, only while studying, I would say it was the easy to transition to C#. To me the biggest obstacles were/is the fact that I did not get the exposure to memory usage, design patterns and coding for performance, that a C/C++ developer would.

Tags:

General

Welcome to PhoenixCode.Net

by Jacobus Meintjes March 26, 2009 09:44

Welcome to my home page.

Site Content
The content for this site will be anything that I find interesting or just about me Tongue out

 

Enjoy the read! 

Jacobus

Tags: ,

General

Powered by BlogEngine.NET 1.6.0.0
Theme by Mads Kristensen | Modified by Mooglegiant

About Me

Jacobus Meintjes
 
C# developer working with ASP.Net and/or Windows Forms.
Email Me

Cumulus

This will be shown to users with no Flash or Javascript.

Widget Twitter not found.

Root element is missing.X