Redirecting Pages, OO Design and Web UI Frameworks

I have some challenges trying to use “Response.Redirect”.  How does it work?

Response.Redirect sends the user to the specified page. You can call it from any page, you just need a reference to the System.Web assembly.

Also add using System.Web.UI.Page at the top of you code.

There are two overloaded versions of the Redirect method.

  • public void Redirect(string url);
  • public void Redirect(string url, bool endResponse);

The second parameter indicates whether to stop running the current page.

You may also like to look at the rather mysterious-sounding Server.Transfer method. This also sends the user to another page but has advantages. It is faster since the transfer is done at the server not the browser. Thus fewer HTTP messages.

You may want to look a our ASP.Net tutorial in C#:

How are interfaces used in OO design?

A good example of using interfaces are the .Net framework classes themselves, particularly the collections classes in System.Collections.

The design stages go something like this:

  1. Isolate the key entities in the problem domain
  2. Extract out all common elements from these entities as base types
  3. Create interfaces the define the base types and their members
  4. Create the base and derived classes that implements the interfaces
  5. You then (in theory!) have a class hierarchy that models the problem domain

The underlying principles are:

When a class implements an interface it must implement all members of the interface
A class can inherit from only one base class but can implements many interfaces.

As a .Net trainer I always found the real purpose of interfaces hard to get across.

You may want to look a our OO tutorial in C#:

Can someone enlighten me to what is so great about MVC and how easy is it for a C# ASP.NET Developer to learn?

The MVC design pattern is very different from web forms. ASP.Net Web Forms focuses on the UI, that is the form and the server controls placed on it. MVC focuses on the model, i.e. the data and business logic. The UI as a set of Views, flow from this.

MVC provides more control over rendered HTML and the page URLs. The page URLs are customizable with MVC’s routing system. Unlike Web Forms URLs do not map to folders and files. The developer works more closely with the way the internet actually works i.e. swapping HTTP messages. This requires more understanding of HTML, HTTP, etc. but allows more customizable and testable web pages.

Web Forms attempted to protect the developer from the complexity of the internet. It provided a powerful set of server controls. These controls automatically rendered as HTML & JavaScript that often became verbose. The ASP.NET code-behind approach encourages developers to mix presentation logic and application logic.

MVC takes a different approach. HTML is again hand crafted but with the help of HTML Helper methods. There is no code behind file. The MVC design pattern encourages developers to put application logic and data in the Model.

Here is an MVC tutorial to build an application from TalkIT:

You may also want to look a our ASP.Net tutorial in C#:

Hope this helps.

Scroll to Top