Back to description
Ever since the first release of the .NET Framework 1.0 in early 2002, Microsoft has put a lot of effort and development time... more
Ever since the first release of the .NET Framework 1.0 in early 2002, Microsoft has put a lot of effort and development time into ASP.NET, the part of the .NET Framework that enables you to build rich web applications. This first release meant a radical change from the older Microsoft technology to build web sites called Active Server Pages (ASP), now often referred to as classic ASP. The introduction of ASP.NET 1.0 and the associated Visual Studio .NET 2002 gave developers the following benefits over classic ASP:
A clean separation between presentation and code. With classic ASP, your coding logic was often scattered throughout the HTML of the page, making it hard to make changes to the page later.
A development model that was much closer to the way desktop applications are programmed; this made it easier for the many Visual Basic desktop programmers to make the switch to web applications.
A feature-rich development tool (called Visual Studio .NET) that allowed developers to create and code their web applications visually.
A choice between a number of object-oriented programming languages, of which Visual Basic .NET and C# (pronounced as C-Sharp) are now the most popular.
Access to the entire .NET Framework, which for the first time meant that web developers had a unified and easy way to access many advanced features to work with databases, files, e-mail, networking tools, and much more.
Despite the many advantages of ASP.NET over the older model, using ASP.NET also meant an increase of complexity and the knowledge you needed to build applications with it, making it harder for many new programmers to get started with ASP.NET.
After the initial release in 2002, Microsoft released another version of the .NET Framework (called .NET 1.1) and the development IDE Visual Studio .NET in 2003. Many people saw this as a service pack for the initial release although it also brought a lot of new things and enhancements in both the framework and the development tools.
In November 2005, Visual Studio 2005 and ASP.NET 2.0 were released. To the pleasant surprise of many developers around the world, Microsoft had again been able to drastically improve and expand the product, adding many features and tools that helped reduce the complexity that was introduced with ASP.NET 1.0. New wizards and smart controls made it possible to reduce the code required to build an application, decreasing the learning curve for new developers and increasing the productivity.
The current version, ASP.NET 3.5, builds on top of the successful ASP.NET 2.0 release, leaving many of the beloved features in place, while adding new features and tools in other areas.
Over the next 18 chapters, you learn how to build full-featured ASP.NET web sites using Visual Web Developer, Microsoft’s development tool for ASP.NET web applications. This book guides you through the process of creating a fully functional database driven web, starting with a bare bones web site in this chapter, all the way down to the deployment of it to a production environment in Chapter 18.
To start off, this chapter gives you a good look at:
Visual Web Developer 2008 Express Edition or Visual Studio 2008 and how to acquire and install it.
Creating your first web site with Visual Web Developer.
The way an ASP.NET page is processed and sent to the browser.
How you can use and customize the development environment.
The chapter closes with an overview of the sample web site that comes with this book, the Planet Wrox web site. In this chapter, you’ll see what the site has to offer and how to use it; the remainder of this book then shows you the inner workings of the site and how it’s built.
Since the sample site and all the examples in this book are built with Visual Web Developer (VWD), it’s important that you have it installed on your development machine, and know how to access its most basic features. The next section shows you how to acquire and install VWD. Once you have it up and running, you’ll see how to create your first web site, followed by an extensive tour through the many features of VWD.
... less
To create good-looking, functional, and successful web sites, you have to understand a number of important technologies and... more
To create good-looking, functional, and successful web sites, you have to understand a number of important technologies and languages, including HTML, ASP.NET, CSS (Cascading Style Sheets), and JavaScript. This and upcoming chapters provide a solid foundation in these technologies, so you should be comfortable with the most important concepts once you’ve finished this book.
Besides these technologies, you also have to understand the Visual Web Developer IDE that was introduced in the previous chapter. You need to know how to create sites, add pages, and manage all the tool bars and windows that Visual Web Developer (VWD) offers you. In addition, you need to know how to build and design web pages in VWD with HTML and Server Controls.
This chapter shows in detail how to create and manage your web sites. It also shows you how to create your ASP.NET web pages and add markup to them, allowing you to create useful web pages that can present information to the user and react to their response.
In particular, this chapter examines:
Two different project types for building ASP.NET web sites
The different project templates that are available to jumpstart your site development and how to use them
The numerous different file types available in ASP.NET and what they are used for
Ways to create structured web sites that are easy to manage, now and in the future
How to use the designer tools to created formatted web pages
Although you already created your first ASP.NET web site in the previous chapter, this chapter starts off with another in-depth look at creating a new web site. As there are many choices to make when you start a new site, it’s important to understand all the different options and pick the right one for your scenario.
The pages you created in the previous two chapters look pretty plain and dull. That’s because they lack styling information... more
The pages you created in the previous two chapters look pretty plain and dull. That’s because they lack styling information and therefore default to the standard layout that the browser applies. To spruce up your pages, you need a way to change their presentation in the browser. The most common way to do this is by using the cascading style sheets (CSS) language. CSS is the de facto language for formatting and designing information on the Web, including ASP.NET web pages. With CSS you can quickly and change the appearance of your web pages, giving them that great look that your design or corporate identity dictates.
Although earlier versions of Visual Web Developer lacked good tools for working with CSS, the IDE of Visual Web Developer 2008 has great support for CSS and is able to render pages much closer to how they’ll eventually end up in the browser. The new tools enable you to visually create CSS, making it much easier to style your pages without the need to know or remember every little detail of CSS.
In this chapter, you'll learn more about the following topics:
What CSS is and why you need it
What the CSS language looks like and how to write it.
The different ways to add CSS code to your ASP.NET pages and to external files.
The numerous tools that VWD offers you to quickly write CSS.
To understand the relevance and need of CSS in your ASP.NET projects, you need to understand the shortcomings of HTML first. The next section gives you a look at the problems that plain HTML presents, and how CSS is able to overcome these issues.
ASP.NET Server Controls are the workhorses of ASP.NET. Almost all the pages you build in VWD will contain one or more server... more
ASP.NET Server Controls are the workhorses of ASP.NET. Almost all the pages you build in VWD will contain one or more server controls. These controls come in all sorts and sizes, ranging from simple controls like a Button and a Label to complex controls that are capable of displaying data from a database like the TreeView and the GridView, which you'll see in Chapters 7 and 12.
Button
Label
TreeView
GridView
The architecture of ASP.NET Server Controls is deeply integrated into ASP.NET, giving the controls a feature set that is quite unique in today's technologies for building web sites.
This chapter shows you what server controls are, how they work, and which ones are available out of the box when you install Visual Web Developer.
In particular, this chapter teaches you the following topics:
What ASP.NET Server Controls are
The different kind of server controls you have at your disposal
The common behavior shared among most of the server controls
How the ASP.NET run-time processes the server controls on your page
How server controls are able to maintain their state across postbacks
The chapter starts off with a general discussion of server controls. You'll see how to define them in your code by dragging them from the Toolbox into Design or Markup view.
The section that follows gives you a thorough look at the many controls that are available in the VWD Toolbox.
In the previous chapters you created a number of Web Forms that contained mostly ASP.NET server controls and plain HTML.... more
In the previous chapters you created a number of Web Forms that contained mostly ASP.NET server controls and plain HTML. Only a few of the examples contained actual programming code, written in either C# or Visual Basic .NET (VB.NET), and most of that code was pretty straightforward. However, coding is an important part of any web site. Although the many smart server controls you have at your disposal minimize the amount of code you need to write compared to the older 1.x family of the .NET Framework or other web technologies like classic ASP or PHP, being able to read, understand, and write code is a critical asset in your web development toolkit.
This chapter teaches you the basics and beyond of programming for web applications. In particular, this chapter looks at:
How to work with objects and collections in a programming environment
Different ways to make decisions in your code
The options available for creating repetitive blocks of functionality
Different ways to write well-organized and documented code
What object orientation is, and how you can use it in your applications
Best of all, just as all the other samples in the book, this entire chapter is covering both VB.NET and C# examples. For every concept or piece of theory introduced in this chapter, you see an example in both VB.NET and C# at the same time. The choice of your preferred language is really up to you.
To get the most out of this chapter, it's recommended to actually try out most of the code examples presented in this chapter. Reading and understanding code is one thing; actually seeing it at work is completely different. Most of the examples can be tested with a simple ASPX page. Drag a Label and a Button on your page, double-click the Button in Design View, and then type the relevant code on the open line of the code block that Visual Web Developer added for you.
Note that some of the examples call fictitious code that won't run correctly. They only serve to illustrate the topic being discussed.
When you're designing and building a web site you should always strive to make the layout and behavior as consistent as possible... more
When you're designing and building a web site you should always strive to make the layout and behavior as consistent as possible. Consistency gives your site a professional appearance and it helps your visitors to find their way around the site. Fortunately, ASP.NET 3.5 offers a number of great features to implement a consistent design. In addition, Visual Web Developer has a set of great tools and a rich Design View helping you create great-looking pages in no time.
In previous chapters you learned how to work with VWD, HTML, CSS, and server controls to create your web pages visually. Chapter 5 introduces you to programming in .NET. This chapter is the first that combines these concepts. You'll see how to write code that applies to all the pages in your site, creating a central location for shared behavior.
In particular, this chapter deals with the following topics that help you create well-designed and consistent web pages that are easy to maintain:
Using master and content pages that allow you to define the global look of a web page
Working with a centralized base page that allows you to define common behavior for all pages in your site
Creating ASP.NET 3.5 themes to define the look and feel of your site with an option for the user to choose their favorite theme at run-time
Creating skins to quickly make site-wide changes to control layout.
The next section shows you how to create a master page that defines the general look and feel of a page. The ASPX pages in your site can then use this master page without the need to rewrite the layout. The remaining sections of this chapter build on top of the master page.
When your site contains more than a handful of pages, it's important to have a solid and clear navigation structure that... more
When your site contains more than a handful of pages, it's important to have a solid and clear navigation structure that allows users to find their way around your site. By implementing a good navigation system, all the loosely coupled web pages in your project will form a complete and coherent web site.
When you think about important parts of a navigation system, the first thing that you may come up with is a menu. Menus come in all sorts and sizes, ranging from simple and static HTML links to complex, fold-out menus driven by CSS or JavaScript. But there's more to navigation than menus alone. ASP.NET comes with a number of useful navigation controls that allow you to set up a navigation system in no time. These controls include the Menu, TreeView, and SiteMapPath, which you'll learn about in this chapter.
Menu
SiteMapPath
Besides visual controls like Menu, navigation is also about structure. A well-organized site is easy for your users to navigate. The site map that is used by the navigation controls helps you define the logical structure of your site.
Another important part of navigation takes place at the server side. Sending a user from one page to another in Code Behind based on some condition is a very common scenario. For example, imagine an administrator entering a new CD or concert review in the Management section of the web site. When the review is done, you may want to show the administrator the full details of it on a new page.
In particular, this chapter looks at the following topics:
How to move around your site using server controls and plain HTML
How to address pages and other resources like images in your site
How to use the ASP.NET Menu, TreeView, and SiteMapPath navigation controls
How to send your user from one page to another through code
Before you look at the built-in navigation controls, you need to understand the different options you have to address the resources in your site like ASPX pages and images.
Besides the master pages, themes, and skins discussed in Chapter 6, ASP.NET 3.5 ships with another feature that allows you... more
Besides the master pages, themes, and skins discussed in Chapter 6, ASP.NET 3.5 ships with another feature that allows you to create reusable and thus consistent blocks of information: user controls.
User controls allow you to group logically related content and controls together which can then be used as a single unit in content pages, master pages, and inside other user controls. A user control is actually a sort of mini ASPX page in that it has a markup section and optionally a Code Behind file in which you can write code for the control. Working with a user control is very similar to working with normal ASPX pages with a few minor differences.
In versions of ASP.NET before 2.0, user controls were used often to create blocks of reusable functionality that had to appear on every page in the site. For example, to create a menu, you would create a user control and then add that control to each and every page in the site. Due to the ASP.NET support for master pages, you don't need user controls for these scenarios anymore. This makes it easier to make changes to your site's structure. Despite the advantages that master pages bring, there is still room for user controls in your ASP.NET web sites as you'll discover in this chapter.
This chapter covers the following topics:
What are user controls and how do they look?
How do you create user controls?
How do you consume user controls in your pages?
How can you improve the usefulness of user controls by adding coding logic to them?
By the end of this chapter, you'll have a firm understanding of what user controls are and how they work, enabling you to create functional reusable blocks of content.
So far you have been creating a fairly static site where you control the layout and content. At development time, you create... more
So far you have been creating a fairly static site where you control the layout and content. At development time, you create your pages and add them to the menu so your users can reach them. You can make your site a lot more attractive by incorporating dynamic data. This data usually flows in two directions: it either comes from the server and is sent to the end user's browser, or the data is entered by the user and sent to the server to be processed or stored.
Data coming from the server can be retrieved from many different data sources, including files and databases, and is often presented with the ASP.NET data controls. You see how to access databases in Chapter 11 and onward.
The other flow of data comes from the user and is sent to the server. The scope of this information is quite broad, ranging from simple page requests and contact forms to complex shopping cart scenarios and wizard-like user interfaces. The underlying principle of this data flow is basically the same in all scenariosusers enter data in a web form and then submit it to the server.
To prevent your system from receiving invalid data, it's important to validate this data before you allow your system to work with it. Fortunately, ASP.NET 3.5 comes with a bag of tools to make data validation a simple task.
The first part of this chapter gives you a good look at the validation controls that ASP.NET supports. You see what controls are available, how to use and customize them, and in what scenarios they are applicable.
The second half of this chapter shows you how to work with data in other ways. You see how to send the information a user submits to your system by e-mail and how to customize the mail body using text-based templates.
This chapter covers the following important topics:
What is user input and why is it important to validate it?
What does ASP.NET 3.5 have to offer to aid you in validating user input?
How do you work with the built-in validation controls and how do you create solutions that are not supported with the standard tools?
How do you send e-mail using ASP.NET?
How do you read text files?
By the end of the chapter, you will have a good understanding of the flow of information to an ASP.NET web application and the various techniques you have at your disposal to validate this data.
Without a doubt, the biggest hype in web development in the past few years is Ajax. Although the technologies that drive... more
Without a doubt, the biggest hype in web development in the past few years is Ajax. Although the technologies that drive Ajax have been around for quite some time, it wasn't until the beginning of 2005 that it got an official name. Ajax, which stands for Asynchronous JavaScript And Xml, allows your client-side web pages to exchange data with the server through asynchronous calls. Probably the most popular feature driven by Ajax is the flicker-free page that allows you to perform a postback to the server without refreshing the entire page.
To enhance your web site with Ajax features you can choose among different Ajax frameworks. Many of these frameworks offer you a set of features and tools including a client-side JavaScript framework to enable Ajax in the browser, JavaScript code for communication with the server, and server controls to integrate with your ASP.NET pages. Although there are a number of different Ajax frameworks available for ASP.NET, the most obvious one is Microsoft ASP.NET AJAX, as it comes with the .NET 3.5 Framework and Visual Web Developer.
Microsoft ASP.NET AJAX gives you a lot more than flicker-free postbacks alone. In addition to the controls that make flicker-free pages possible, Microsoft ASP.NET AJAX gives you a few more server controls to create rich, interactive, and responsive user interfaces.
In addition to the server control–based part of Ajax, the ASP.NET AJAX Framework also comes with a rich client-side framework. This framework enables your JavaScript to communicate with the server by means of Web Services. It also allows you to access the entire client-side page using an intuitive code model that works the same, regardless of the browser you're targeting.
In previous versions of ASP.NET and Visual Web Developer, Ajax was available as a separate download and add-on. Fortunately, Ajax is now fully integrated in VWD and ASP.NET, making it easy to get started with it.
This chapter looks at the following Ajax-related topics:
Using the UpdatePanel control to avoid page flicker
UpdatePanel
Understanding the ScriptManager control that enables the Ajax functionality
ScriptManager
Using the UpdateProgress control to notify users about progress of the Ajax operation
UpdateProgress
Using triggers and the Timer control to trigger the update of UpdatePanel controls
Timer
Creating Web Services that are accessible by your client-side script
By the end of the chapter, you should have a good understanding of the various server controls that the ASP.NET AJAX Framework has to offer. In addition, you should have a basic understanding of creating Web Services in the ASP.NET world and how you can call them from client-side JavaScript code using the client-side Ajax Framework.
Being able to use a database in your ASP.NET 3.5 web sites is just as critical as understanding HTML and CSS: it's almost... more
Being able to use a database in your ASP.NET 3.5 web sites is just as critical as understanding HTML and CSS: it's almost impossible to build a modern, full-featured web site without it. Databases are useful because they allow you to store data in a structured way and enable you to retrieve that data in a structured way again. The biggest benefit of databases is that they can be accessed at runtime, which means you are no longer limited to just the relatively static files you create at design time in Visual Web Developer. You can use a database to store reviews, musical genres, pictures, information about users (user names, e-mail addresses, passwords and so on), log information about who reads your reviews, and much more, and then access that data from your ASPX pages.
This gives you great flexibility in the data you present, and the way you present it, enabling you to create highly dynamic web sites that can adapt to your visitor's preferences, to the content your site has to offer or even to the roles or access rights that your users have.
To successfully work with a database in an ASPX page, this chapter teaches you how to access databases using a query language called SQLor Structured Query Language. This language allows you to retrieve and manipulate data stored in a database. You will also see how to use the database tools in VWD to create tables and queries.
Although ASP.NET and the .NET Framework offer you many tools and technologies that allow you to work with databases without having a firm knowledge of the underlying concepts like SQL, it's still important to understand them. Once you know how to access a database, you'll find it easier to understand other technologies, like LINQ to SQL, which provides easier access to database operations directly from code.
This chapter serves as an introduction to working with databases. In particular, it looks at:
What is a database, and what databases are usually used with ASP.NET pages?
What is SQL, how does it look like and how do you use it?
How do you retrieve data from a database using the SELECT statement?
SELECT
How do you manipulate data in a database using other SQL constructs?
What are database relations and why are they important?
What tools do you have available in VWD to manage objects like tables and queries, and how do you use these tools?
In the chapters that follow, you apply the things you learn in this chapter. In Chapter 12, you'll see how to use built-in controls to work with data in your database. In Chapter 13, you see how to use LINQ as an additional layer on top of your database to access data in an object oriented way with minimal code.
In the following sections, you see what a database is, and what different kinds of databases are available to you.
Now that you have seen how to interact with databases using SQL it's time to put that knowledge into practice and start building... more
Now that you have seen how to interact with databases using SQL it's time to put that knowledge into practice and start building some useful pages that allow you manage the data in your web site.
In this chapter you learn how to display, insert, update, and delete data using the popular data controls that ship with ASP.NET. Besides working with the visual controls that are used to display and edit data in a web page, you also learn how to work with the SqlDataSource control that acts as the bridge between the database and your ASPX pages.
SqlDataSource
In particular, this chapter gives you a good look at the following topics:
Controls that display and maintain data in your web site
How to display data using the GridView control
How to access the database to retrieve and update data using a SqlDataSource control
How to insert, edit, and delete data using the data controls like the GridView and the DetailsView
DetailsView
How to create a rich interface that allows a user to insert and edit data while maintaining data integrity with the ASP.NET validation controls
The best way to store your connection strings in your application so they are easily updateable
The first things you need to look at are the available data controls, discussed in the next section.
If I had to choose my favorite new feature in .NET 3.5, I'd probably pick LINQ, the new query language that is tightly integrated... more
If I had to choose my favorite new feature in .NET 3.5, I'd probably pick LINQ, the new query language that is tightly integrated with the programming languages used in the .NET Framework. LINQ stands for language-integrated query and enables you to query data from within .NET programming languages similar to how SQL allows you to query data in a database. In fact, the LINQ syntax has been modeled partially after the SQL language, making it easier for programmers familiar with SQL to get started with LINQ.
LINQ comes in a few different implementations, allowing you to access and query a wide variety of sources including collections in your own code, XML files, .NET DataSets, and SQL Server databases from your VB.NET or C# code. In the next section you get a brief overview of the main LINQ pillars while the remainder of the chapter focuses on that part of LINQ that enables you to query Microsoft SQL Server databases, called LINQ to SQL.
In addition to the LINQ syntax that is now part of the two most popular programming languages, C# and Visual Basic, the .NET 3.5 Framework ships with a few additional tools that make using LINQ in your projects a smooth experience.
Additionally, the new LinqDataSource control allows you to hook up data-bound controls to LINQ-compatible data sources directly. You'll see how to consume and configure this control in the second half of this chapter.
LinqDataSource
This chapter introduces you to both the LINQ language and its syntax, as well as to the numerous ways you can use LINQ data in your ASP.NET projects. In particular, this chapter examines the following topics:
What is LINQ and what does its syntax look like?
What different forms of LINQ are available and when are they appropriate?
How do you create LINQ to SQL Classes and how can you query them in your ASPX pages?
How do you configure and use the new LinqDataSource control to access LINQ data sources in your ASPX pages?
How can you use the new ListView and DataPager controls together with LINQ to create flexible, data-driven web pages with little to no code.
ListView
DataPager
In the previous three chapters you have been introduced to a lot of new concepts. Chapter 11 discusses databases in general... more
In the previous three chapters you have been introduced to a lot of new concepts. Chapter 11 discusses databases in general and SQL Server 2005 Express Edition in particular. The chapter also covers the basic CRUD operations to create, read, update, and delete data that is stored in a database. Chapter 12 focuses mostly on working with the SqlDataSource control and the different data-bound controls that you have at your disposal. Finally, the previous chapter explores the world of LINQ, Microsoft’s latest data access strategy designed to speed up the way you write data access code.
To help you to really understand the core concepts of data access, those three chapters focus mainly on the data source controls and the principles behind them, and much less on the presentation of data with the data-bound controls. Obviously, in a real-world application this is not enough and you need a way to present data in a clear and attractive way.
The data-bound controls that ship with ASP.NET 3.5 all provide the necessary options to change the way data is presented. They allow you to completely change the design (font, colors, spacing, and so on) of the data they are presenting. Additionally, you can tweak these controls to hide specific columns, modify column headers, or even colorize odd rows different from even rows. Finally, because of the rich event model that drives the data-bound and data source controls, you can change the look and feel of the controls conditionally. For example, you can hide the Delete link on the Genres management page for those genres that still have reviews attached to them.
Besides pages that look good, your application can also benefit from speed to make a good impression on your users. Good performance is always a welcome ingredient of any popular web site. ASP.NET comes with great caching capabilities that help you speed up the application.
This chapter shows you how to implement these concepts in your own web site. In particular, you see how to do the following:
Change formatting of the various data-bound controls using styles
Combine styles, themes, and skins to create good-looking and easy to maintain web sites
Use the various events that are fired by the data controls to change the appearance of your data controls conditionallyfor example, to hide or disable certain controls in the user interface when it doesn't make sense to have them visible or enabled
Use the built-in caching mechanisms to improve the speed of your web site
Until now you have created pages in your web site that are accessible to all visitors to your site. You don't have a way... more
Until now you have created pages in your web site that are accessible to all visitors to your site. You don't have a way to block certain resources like ASPX files or even whole folders for specific users. That means, for example, that currently anyone can access your Management folder and start messing with the genres and reviews in the system.
Clearly, this is not something you'd want in a production web site. So, you need to think of a good security strategy to stop unwanted users from accessing specific content. You also need to look at a mechanism that allows users to sign up for a new account and at the same time allows you to designate certain users as managers of your web site and grant them special access rights.
Fortunately, ASP.NET 3.5 ships with all the tools you need to create a solid and safe security mechanism. In this chapter you learn how to make use of these tools in your ASP.NET web site.
Important terminology you'll encounter when dealing with security
The ASP.NET application services that enable security
How you can let users sign up for an account for your site using built-in server controls
How users can independently reset their passwords or request new ones
How you can manage the users and roles in your database at development time
How you can present different content to different users based on their access rights in the system
Before you start looking at how security is implemented in the ASP.NET Framework, you need to understand a few important terms that you'll come across in every discussion on security.
There is only one thing that beats good content on the webgood personalized content. In the era of information overload... more
There is only one thing that beats good content on the webgood personalized content. In the era of information overload and the huge amount of competitive sites, it's important to know your visitors and understand the possibilities you have to present personalized content. With a good personalization strategy you can create a web site that lives up to your user's expectation by presenting them with exactly the data they are looking for. Personalization is useful for many different scenarios: on a sports site you use it to highlight activities from the user's favorite team. On a site that deals with programming, you can personalize content by showing the user examples in their preferred programming language(s) only. On a news web site, you can let a user choose one or more news categories (World, Local, Sports, Business, Financial, and so on) and target the content you show them based on these preferences. You can take this one step further by sending them e-mail updates when a new article is posted in one of those categories.
However, personalization goes further than just storing personal preferences and adapting the content to these preferences. With personalization you can also keep track of other user details, like names, date of birth, visits to the site, items users bought in an online shop, and so on. You can then use these details to further personalize web pages, creating a closer relationship with your visitor.
In the Planet Wrox web site, personalization is implemented simply yet effectively. The Reviews page only shows the reviews for those genres that the user is interested in. To see all the available reviews, users can still visit the All.aspx page but by visiting the personalized page, they only see reviews in genres they really like.
Additionally, users can enter personal details about themselves, like first and last name, and a short biography. These details will be shown in the Photo Albums section of the site so you know who uploaded a particular photo album.
To allow you to add personalization features to a web site, ASP.NET 3.5 ships with an application service called Profile. With the Profile service you can store data for a particular user with very few lines of code.
The chapter looks at the following topics:
The Profile feature that ships with ASP.NET
How to create and consume a user's profile in a web site
How you can recognize your users and how to serve them different content
How you can access the profile of other users in the site
By the end of this chapter, you have enough knowledge about the personalization features brought by the Profile to create dynamic and personalized web sites.
You can't make an omelet without breaking eggs and you cannot write code without creating bugs. No matter how hard you try... more
You can't make an omelet without breaking eggs and you cannot write code without creating bugs. No matter how hard you try and how good you are, your code will contain problems that affect the behavior of your web site.
Of course you should strive to minimize the impact of these bugs, aiming for a "zero bug count." To aid you in this, the ASP.NET run-time and Visual Web Developer provide you with a number of tools.
First of all, the languages supported by .NET implement exception handling, a methodology to identify and handle errors that occur at run-time. By handling these errors, you can present your users a friendly error message. At the same time you can log these errors, giving you a chance to fix them before they reoccur. In this chapter you see how exception handling works, and how to log your errors by e-mail.
Before your code goes into production you need to write and debug it first. To help you debug your code, VWD comes with a rich toolset that includes ways to step through your code line by line, look at your variables and objects at run-time, and even change them as you go. The toolset also provides you with valuable information about the execution path your code follows: the path that your application takes through your code, following methods, event handlers, If and Else statements, and so on.
If
Else
How to write code that is able to detect and handle errors that occur at run-time, at the same time shielding your users from the error details and give them an understandable explanation instead
How to detect errors that occur on your production machine so you can take counter measures
What debugging is and what debugging tools Visual Web Developer offers
What tools you can use to gain information about your system while it's running in a development or production environment
Congratulations! The fact you're reading this chapter probably means you now have a full-featured, database-driven ASP.NET... more
Congratulations! The fact you're reading this chapter probably means you now have a full-featured, database-driven ASP.NET web site that you are ready to release into the wild. It's an exciting time for you and your project. Pretty soon your application will be used and judged by your target audience.
To make your web site accessible to users on the Internet, you need to publish it to a production server that is connected to the Internet. What kind of server this is and where it is located depends on your own requirements and budget. You can host the site on a home server in your attic with a private Internet connection or you can host it with an external (and often commercial) party with a direct connection to the Internet backbone.
Either way, some work needs to be done to get your site from its development location at C:\BegASPNET\Site to a location where it's accessible over the Internet.
This chapter deals with a few topics related to successfully deploying your web application. You'll learn about the process from preparing your application in the development environment to actually running and testing it at your production server.
In particular this chapter looks at the following topics:
How to ease the deployment process through simple changes to your code and configuration
How to prepare your site for deployment by creating a copy using Visual Web Developer's built-in copy tools
How to install and configure a web server and your web site on your target machine
How to avoid common errors you may get when deploying a site
How to copy data stored in your SQL Server 2005 databases to the target server
The chapter then ends with a list of things you need to take care of when deploying an application. You can use this check list to help you make sure you configure your production site in the most secure and optimal way.
At the end of each chapter, you find exercises that help you test the knowledge you gained in this chapter. You find the... more
At the end of each chapter, you find exercises that help you test the knowledge you gained in this chapter. You find the answers to each question in Appendix A at the end of this book.
This book assumes that you are using Microsoft SQL Server 2005 Express Edition as the database for the Planet Wrox project... more
This book assumes that you are using Microsoft SQL Server 2005 Express Edition as the database for the Planet Wrox project. SQL Server 2005 Express Edition is great for development because it's free, relatively lightweight, and easy to use. However, in a production environment it doesn't always cut it because it isn't designed to handle lots of users simultaneously. In cases where the Express Edition is not enough, you need to look at its bigger brothers: the commercial versions of SQL Server 2005, like the Standard or Enterprise Editions. In this appendix you will learn about security in SQL Server 2005, how to enable your SQL Server 2005 database and your ASP.NET 3.5 application to work together, and how to obtain and use SQL Server Management Studio Express, a free tool from Microsoft that lets you manage your database.
Although this appendix doesn't discuss SQL Server 2000, you'll find that most of the concepts apply to this older version of SQL Server as well. In fact, you can even use SQL Server Management Studio Express to manage your SQL Server 2000 database.
In addition to configuring your SQL Server and ASP.NET 3.5 application to work together, this appendix also shows you how to configure a SQL Server database to support the ASP.NET 3.5 application services. This is necessary if you want your application to use your own, custom database instead of the aspnetdb.mdf database that is generated for you automatically.
Purchase Before purchasing this product, please be sure you have met all software and system requirements, and that you understand any limits placed upon its use.
Return Policy Wrox Chapters on Demand are non-returnable and non-refundable.
Reader Software Wrox Chapters on Demand are offered as PDFs, and they must be viewed using the Adobe Reader. If you do not have the Reader installed, it can be downloaded for free at Adobe.com.
Test Download As Wrox Chapters on Demand purchases are non-returnable, it is advisable that you test your system and software configurations with a free sample download before you place an order.
Usage Rights for a Wrox Chapter on Demand File Any Wrox Chapter on Demand product you purchase from this site will come with certain restrictions that allow Wiley to protect the copyrights of its products. After you purchase and download this title, you:
If you have any questions about these restrictions, you may contact Customer Care at (877) 762-2974 (8 a.m. - 5 p.m. EST, Monday - Friday). If you have any issues related to Technical Support, please contact us at 800-762-2974 (United States only) or 317-572-3994 (International) 8 a.m. - 8 p.m. EST, Monday - Friday).
Related Books