Part of feedburner.com
Software development articles by Kory Becker. Javascript, artificial intelligence, data science, .NET, databases, UI design, web services, and more.
A common task for many MVC3 C# ASP .NET web applications is the creation of a login form. Along with the common login form comes an array of required functionality, including login validation, authentication, storing of credentials, and of course, security. In traditional C# ASP .NET web applications, protected pages would sit within a particular folder, designated by the web.config as a protected area. However, in MVC3 controllers rule the land and application folders may be virtual, thus requiring a controller-based security technique.
In this tutorial, we'll walk through creating a slick login form for an example MVC3 C# ASP .NET web application. Our login form will be styled with CSS3, contain rounded edges, a gradient background, and a lens flare highlight effect. Our login form will also contain ....
Introduction The navigation menu is a common control on almost every MVC3 C# ASP .NET web site, containing sets of links for navigating to various portions of the web site. Traditionally, menu navigation links are statically embedded within an MVC3 control or directly within the HTML of a web page. Occasionally, the need may arise for navigation links to be driven from an outside data source, such as a database, XML file, or CMS (content management system). In particular, CMS content management systems often allow users to dynamically configure web site content, including navigational links. A user may choose to add or remove top-level navigation items, which in turn, instructs the CMS system to publish a differing set of navigation data. In this scenario, we would need to design our MVC3 C# ASP .NET web application to dynamically load the navigational items from a file or data-store, for display in the MVC view. In this tutorial, we'll walk through creating a simple top-lev ....
Introduction Debugging software applications typically occurs within the context of an IDE (integrated development environment), such as Eclipse, XCode, Visual Studio, etc. This allows developers to step line by line through sections of code, analyzing variables, and tracing the stack. Occasionally, developers may be unable to debug within the IDE, whether due to software complexity, runtime environments, or other issues. During these conditions, resourceful developers may utilize more primitive, but equally powerful methods of debugging, such as raw printing of values and steps (printf, cout, alert statements, etc). However, when the software process executes in a remote server environment, where the developer may not have access to the local file system, debugging can take on additional complexity. Common remote debugging solutions include writing logs to the file system, email, or remote web service methods. In this tutorial, we'll d ....
Introduction Web services are an important part of the architecture for many software systems. While many web applications use JavaScript AJAX requests to make calls to local web service methods, occasionally the need arises to call outside web services to retrieve data for the current request. Examples include mashup web applications, interconnected business applications, or web page widgets (for example, Google Adsense, Twitter scrollers, Facebook comment streams, etc). While client script can certainly call local web service methods, calling outside web services from non-local domains violates the cross-domain policy. To work around this policy, an additional tactic is required.
In this tutorial, we'll create a simple C# .NET web service that creates monsters and returns them in JSON format. We'll create a simple web page that uses a JavaScript AJAX request to display a monster each time a button is clicked. To simulate an outside web service, we'll modify the loca ....
User interfaces for software applications can come in a variety of formats, ranging from command-line, graphical, web application, and even voice. While the most popular user interfaces include graphical and web-based applications, occasionally the need arises for an alternative interface. Whether due to multi-threaded complexity, concurrent connectivity, or details surrounding execution of the service, a chat bot based interface may suit the need.
Chat bots typically provide a text-based user interface, allowing the user to type commands and receive text responses. Chat bots are usually stateful services, remembering previous commands (and perhaps even conversation) in order to provide functionality. A popular example from recent Internet history is the usage of IRC chat bots, often used for monitoring chat rooms, playing games, and providing help. The same technology can be used today, but to provide even more powerful functionality, such as serving busi ....
Introduction It's common in ASP .NET Web Forms to create user controls that encompass frequently accessed user interface components. WebForms user controls can be created which allow setting of properties, customization, and placement on any aspx web form for display of content. However, with ASP .NET MVC (Model View Controller), the creation of user controls typically follows a slightly different approach. In particular, without the usage of Session or the traditional WebForms event model, it can be difficult to create the types of user controls many WebForms developers are familiar with. While you can certainly embed WebForms user controls within an ASP .NET MVC web application, it could be considered good practice to follow the traditional MVC architecture with the creation and usage of partial view user controls. In this tutorial we'll create a gradient color box user control with ASP .NET MVC 3 and Razor by using a Partial View. We'll display our ASP .NET MVC 3 Partial ....
Introduction The chief argument for a web service is to provide a platform and language independent means of accessing a software API. This allows client programs, written in a variety of programming languages, to interact with the web service. Of course, web services also provide additional benefits, including the ability to scale in response to client traffic, provide additional security layers, and, as long as the interface contract doesn’t change, they also provide easier management of updates to the originating API code. In this article, we’ll create a basic C# ASP .NET WCF web service for a “Hello World” example. We’ll then create a client application using Perl / CGI to consume the web service and call the web service target method. Through the usage of XML and SOAP, we’ll be able to easily communicate with the WCF web service (through any number of programming languages) and display the results.
Introduction Creating your own programming language can be a daunting task. After all, that's why developers choose existing programming languages, such as C#, Ruby, Perl, JavaScript or other traditional languages. However, in certain instances, a case may arise where non-developer business users may be required to configure and modify programming logic. Since not all business users can be programmers in the native programming language, it may be beneficial to implement a domain specific language that 3rd-party users can utilize. Simple examples of such a language might include Windows INI files or XML configuration files. However, we can create an even more specific custom programming language, just for our software purposes, by using an External Domain Specific Language. Domain specific languages (DSL) can provide enhanced readability and understanding of programming code, particularly by non-developers. Where regular programming code might exist, a domain specific languag ....
Introduction C# ASP .NET web applications have grown to encompass varying degrees of complexity and enterprise-level flexibility. With the latest release of the Microsoft ASP .NET MVC Model View Controller (Release Candidate) framework, C# web applications can be designed using the fluent view template language, Razor, to rapidly develop MVC Views and web application user interfaces. By combining the ASP .NET MVC Razor framework with a database layer, featuring the new NoSQL solution RavenDB, we can develop an enterprise-suitable solution for querying the NoSQL database and managing entities. In this article, we'll create an example C# ASP .NET MVC Razor web application, using the RavenDB NoSQL database as the backend. Our web application will automatically generate random flying creatures and monsters, each with their own randomly generated magical weapon. The flying creatures will be created and stored in the NoSQL document database and displayed within an AJAX jQuery base ....
Introduction The majority of C# ASP .NET web applications are often developed with the intention of running in a single web server environment. They'll often take advantage of ASP .NET's Session State to store variables and data on the server, per user. As an ASP .NET web application grows in usage and popularity, scalability issues may arise, as the single web server is brought to its maximum capabilities. Whether due to overload of the server's resources or simply as an enterprise fail-safe architecture, expanding the hosting environment to encompass multiple web servers and processors is often the next step for a growing enterprise-level C# ASP .NET web application. In this article, we'll take a look at several solutions for scaling a C# ASP .NET web application across a web garden, web farm, and beyond. In particular, we'll focus on implications of Session State and potential solutions for scaling session across multiple processors and servers. We'll also view an example ....
Introduction
Silverlight is a graphical toolkit for providing advanced visual displays and animation in web pages, using C# ASP .NET. The Silverlight API contains a flexible list of graph and chart controls, used for visualizing a vast array of data. As the Silverlight graph and chart controls are highly flexible, they provide the ability to apply custom styles and effects, changing the appearance of standard chart, graph, and grid controls.
In this tutorial, we'll walk through creating a C# ASP .NET Silverlight web application for visualizing financial stock market data. Our Silverlight graph will display dividend amounts paid for a specific stock, equity, or bond over time. Our graphs will actually model a similar style to the Google Analytics chart display, providing an easy and modern way to view financial data. The dividend data will be retrieved using a WCF Windows Communication Found ....
Introduction
Web application data access layers have evolved over time to provide increasing flexibility and maintainability in software architecture. Often, many web applications begin by manually maintaining database connections and SQL query strings. However, as architecture designs grow, more web applications are using ORM models to help increase code reuse and maintainability of ever-growing C# ASP .NET web applications.
The latest version of the Entity Framework EF4 provides several new features, which support implementing a loosely-coupled repository pattern design. Using the Repository Pattern, along with a UnitOfWork pattern, we can greatly enhance the maintainability of our web applications with a solid architecture, greater code reuse, and unit test capability.
In this article, we'll step through 3 methods of accessing the Entity Framework data access layer in C# ASP .NE ....
Introduction The Windows Communication Foundation WCF is growing in popularity and becoming the mainstream method for creating web services. While WCF can provide a powerful interoperable service, which many different programs and languages can comminute with, it becomes increasingly important to be able to debug the web service's action at the raw SOAP XML level. Microsoft provides a built-in tool for viewing WCF log files, although it lacks the simplicity of quickly displaying the raw XML sent to and from the WCF service. Luckily, we can utilize the .NET message inspector to add support for our WCF service to output the complete XML SOAP packets that are sent and received. In this tutorial, we'll create a basic WCF web service using plain-text username and password authentication. We'll bypass using SSL and x.509 certificates to keep things simple. We'll then add a custom attribute to our WCF class to output all incoming and outgoing XML SOAP packet messages to the Visual ....
Introduction A large variety of ORM object relational mapping tools exist for use with developing C# ASP .NET web applications. Some of the more popular ORM tools include LINQ to SQL, the Entity Framework, and NHibernate. While previous articles have discussed developing web applications with LINQ to SQL and the Entity Framework through the usage of the business object generator, Linquify, in this tutorial, we'll focus on implementing the repository pattern for an NHibernate web application.
Repository Pattern vs Business Objects Before discussing the details of implementing the repository pattern with NHibernate, it's important to note the difference between the repository model of data storage versus the business object model. The repository model consists of an individual class which accepts and returns type objects, includi ....Introduction Linquify is a Visual Studio add-in and business class generator for LINQ to SQL and the Entity Framework, providing quick and easy development for ASP .NET data layers. In this tutorial, we'll go through the steps of setting up a basic C# ASP .NET web application, which populates a DropDownList control with people from a database table. The user can select a person and click the View button to view additional details about the person, including information from relational tables. We'll use the Entity Framework as our data access layer, combined with Linquify for our business class type library.
Starting the Project To begin our C# ASP .NET web application, we'll create a new web application project in Visual Studio, called "DropDownListLinquify". Before we get started with the user interface code, let's ....Introduction Linquify, our recently released Visual Studio Add-in, is a .NET business class generator for LINQ to SQL and the Entity Framework, providing quick and easy development for ASP .NET data layers. In this tutorial, we'll demonstrate some of Linquify's features by guiding you through the architecture and development of a Silverlight ASP .NET web application utilizing Linquify. The ASP .NET web application will bind a database containing people to a Silverlight DataGrid and allow adding, editing, and deleting of individual people. The web application will use Silverlight as the user interface to demonstrate the use of Linquify as a data access layer, regardless of the GUI user interface implementation. We'll also create a WCF web service to function as an intermediate business layer.
Getting the Tools for Silverlight Development The first ....Introduction Many ASP .NET business web applications involve the usage of a database in one form or another. Depending on the architecture of the web application, database calls may exist in the user interface, business tier, or data tier. Regardless of the layer, many developers include raw SQL query strings within their source code, for accessing the database. In fact, since the database classes accept a raw SQL string as a parameter when beginning a query or stored procedure call, it's common for developers to include the SQL query string directly in the source code. While as simple and straight-forward as this technique is, it introduces a variety of maintenance problems, including requiring a recompile whenever an SQL string is tweaked, complicating the source code with long SQL strings, and string concatentation of parameters in the SQL query which is prone to errors.
In this article, we'll de ....Introduction Writing a C# ASP .NET web application which utilizes a database can create increasingly complex code. The more complex code gets, the more difficult it becomes to debug, maintain, and enhance. The Repository design pattern is a way of introducing architecture into your C# ASP .NET web application, which creates a clear layer of separation between your web forms and database accessible layers. The Repository pattern helps organize a web application to form a 3-tier architecture and provide loosly coupled classes, which can be reused in future C# ASP .NET web applications and easily updated. In this article we'll implement a Repository Pattern for an example C# ASP .NET application which deals with planets in the solar system. The example application will contain 3-tiers, including the user interface, business logic layer, and database layer via the Repository design pattern.
A Repositor ....Introduction
Sending email notifications from C# ASP .NET web applications can often become a troublesome process. Automatic emails from software may be marked as junk or spam by many ISP mail servers. This can make it difficult for users to properly receive email notifications from software products and the messages themselves can be very important to the user. While one solution may be to ask users to add your web applications email address to their junk mail filter's safe-list, this process can be difficult to control and unreliable. A possibly better solution is to use a 3rd-party email service to route messages through, such as Gmail.
In this article, we'll create a basic C# ASP .NET web service which sends emails using Gmail's SMTP server and your own Gmail account. The web service that we'll create can by used by any range of applications, written in any programming language, simply by communicating with the web service in XML to send emails.
Introduction
Cellular automata is a model of artificial intelligence involving the creation of single-celled programmatic life forms, within a computer program. John von Neumann, the first scientist to implement cellular automata, came about the discovery while in search of a way to create self replicating robots. He devised a specific set of rules guiding the life, death, and reproduction cycle of each cellular automata cell. When put into action, cellular automata can create increasingly complex patterns, which seem to imitate forms of bacterial life, right on the computer screen. While the patterns it produces can be quite complex, the C# .NET code is surprisingly easy. In fact, the Wolfram Alpha computation engine is based, in part, upon cellular automata.
In this article, we'll create our very own artificial intelligence bacteria by implementing cellular automata with the rule set from Conway's Game of Life. To keep things interesting, we'll also use the Str ....
Introduction
Neural networks are one of the methods for creating artificial intelligence in computers. They are a way of solving problems that are too difficult or complicated to solve using traditional algorithms and programmatic methods. Some believe that neural networks are the future of computers and ultimately, humankind.
In this article, we'll describe how to implement a neural network in C# .NET and train the network using a genetic algorithm. Our networks will battle against each other for the survival of the fittest to solve the mathematical functions AND, OR, and XOR. While these functions may seem trivial, it provides an easy introduction to implementing the neural network with a genetic algorithm. Once the neural networks evolve to solve the easiest of mathematical functions, one could create much more powerful networks.
The Neural Network is a Brain
The neural netw ....
Introduction
With the release of the ASP .NET MVC (model view controller) framework for Visual Studio and .NET, many developers are considering the move to the new MVC architecture, in place of classic ASP .NET. The MVC framework for C# ASP .NET provides a loosely-coupled and robust architecture for creating web applications, with distinct separation of the user interface, UI logic, and business logic layers. However, in addition to the logic architecture, the MVC pattern diverges from classic ASP .NET even more.
In this tutorial, we'll examine how to create a basic ASP .NET MVC application, which allows entering a zip code and asynchronously displaying the city and state associated with a zip code via AJAX and jQuery.
One Degree Away From Classic ASP .NET
ASP .NET WebForms centered around the idea of callbacks and events. Controls, such as buttons, would fire events back to the cod ....
Introduction
There are a lot of different entities crawling around your web applications in the wild, including web browsers, web crawlers, web spiders, web bots, and automated scripts. Determining the difference between a regular user visiting your site and an automated web bot can help aid you with more accurately recording statistics, customizing content, and optimizing web application performance.
The .NET framework, used to create C# ASP .NET web applications, actually comes with a built-in web browser detector, called the BrowserCaps feature. .NET 2.0 adds an additional detector, called the .Browser feature. Regardless of the .NET version, determining the difference between a user's web browser and an automated web crawler can make a big difference in a web application, and it's easy to do.
In this article, we'll discuss three methods for determining the web browser type. We'll also describe how to tell the difference between a user's web browser and ....
Introduction
LINQ is one of the most popular Microsoft technologies for reading and writing to SQL Server databases. LINQ to SQL builds upon LINQ technology to allow working with business objects, generated from the database tables. Tranditionally, LINQ to SQL is compatible with SQL Server databases and does not easily support other database formats. Since LINQ is a leap forward for developers accessing databases, it's important to be able to use LINQ with other popular database formats as well. This article describes how to use LINQ to SQL with a MySQL database in C# ASP .NET.
The Old Way of Doing Things
Prior to LINQ, working with databases from C# ASP .NET web applications involved handling database connections, SQLConnection and SqlCommand objects, and working with data readers. While this technique provided a lower level of approach to database interactivity from C#, it was also more pr ....
The following is a fix for an issue with slow queries in DbLinq when using MySql. The problem causes very slow MySQL queries when using LINQ to SQL with DbLinq, and displays a list of ArgumentExceptions, thrown before the query is executed. The query can take up to 8-10 seconds to execute.
Here is a work-around fix for the issue:Download SVN patch 1Download SVN patch 2
1. Download the latest SVN code for DbLinq at http://code.google.com/p/dblinq2007/source/checkout
2. Open the following file for editing in Visual Studio 2008 DBLinq\src\DbLinq\Data\Linq\Sugar\Implementation\ExpressionOptimizer.cs
3. On line 78, the problem manifests itself when attempting to evalu ....
Introduction
Redirecting a user after login to a C# ASP .NET web application is a common feature found in most web applications. It's also quite common to have multiple types of users logging into the ASP .NET web application, differing by the type of role membership they belong to, and each requiring a redirect to their specific landing page. While this can certainly be achieved with a couple of Response.Redirect() calls, you can create a much more robust automatic redirect-by-role solution.
This article describes how to automatically redirect users upon login, based upon their role membership. Since the list of redirect URLs may change frequently, we'll store them conveniently within the web.config configuration file. New user roles and redirect URLs can be added without recompilation of the C# ASP .NET web application.
On First Thought, It Isn't Pretty
When thinking about redirecting users ....
Introduction
Sooner or later many web sites realize they need to allow users to login to their C# ASP .NET web applications. This can be as a result of web application functionality, feature restrictions, or simply to gauge web site traffic better by keeping track of users in the .NET application. The good news is that adding login functionality to your C# ASP .NET web application is easier than ever. By taking advantage of the built-in ASP .NET login control, membership providers, and role providers, you can quickly take care of authenticating, authorizing, and logging users in to your .NET web application.
In this article, we'll step through the process of using the built-in ASP .NET login control and wiring it up to a custom membership provider and a custom role provider class. We'll walk through configuring the C# ASP .NET web.config file to specify roles and access within the web application. To add some spice, we'll also include a way to automatically sign ....
Introduction
With the latest release of C# ASP .NET 3.5, Visual Studio 2008, and LINQ, there is a whole new way of working with the data layer in C# ASP .NET web applications. Prior to LINQ, many developers would either generate or custom-code a data layer based upon the usage of SqlConnection, SqlCommand, and DataReader objects to manipulate data. With LINQ and LINQ to SQL, we no longer need to rely on the details of the connection objects and can instead begin thinking more abstractly by using the pre-generated LINQ business objects and the data access layer. In this manner, LINQ has brought a conformity to the data layer in ASP .NET web applications. However, as with any new technology, new architectures often arise to support them. As we continue on, you'll see how to implement your own tiered architecture, specifically for populating datasource controls.
In this article, we'll visit three ways to populate a DropDownList control by binding to a data source. W ....
Introduction
The State Pattern is an interesting design pattern in that it allows us to separate out portions of code into individual related modules, or states. This pattern is particularly useful for applications which need to retain state information, such as the current phase a program is in. While you can typically maintain this information using a basic integer variable, the State pattern helps abstract the specific state logic, reduces code complexity, and greatly increases code readability. This can make the difference between an application maintenance nightmare and a work of art.
This article describes how to use the State Pattern with C# to create a simple, console-based RPG role playing game. You'll be able to see exactly how the State pattern fits into the flow of the rpg game and how it easily cleans up the code, in what might typically be a confusion of integer values and if-then statements.
Introduction
C# ASP .NET has a setting in the web.config file which allows selecting the desired session timeout. When the session timeout value expires, the currently logged in user's session is deleted and the user is directed back to the login page. The default timeout value usually hovers around 20 minutes for ASP .NET's session timeout. While this is the expected behavior, often clients may require the session timeout to be increased dramatically or even avoid any timeout at all while the user is logged in.
This article describes a solution for web applications which require a session to never timeout or for those who have a session timeout occurring before the value set in the web.config. The solution is invisible and seamless and has been tested in Internet Explorer, Firefox, and Safari.
Why Would a Client Want No Session Timeout?
A typical scenerio where a user may want to ....
Introduction
The Iterator design pattern provides us with a common method of enumerating a list of items or array, while hiding the details of the list's implementation. This provides a cleaner use of the array object and hides unneccessary information from the client, ultimately leading to better code-reuse, enhanced maintainability, and fewer bugs. The iterator pattern can enumerate the list of items regardless of their actual storage type.
The Iterator design pattern is actually a quite common pattern in most object oriented programming languages, especially in C# and Java. In fact, both languages include their own pre-built Iterator pattern, which can be inherited from. Of course, knowing how to create your own Iterator design pattern can provide great benefits and allow you to expand your design when needed.
This article will describe three ways to traverse a list of items, from simply walking the array, to using the built-in C# ASP .NET IEnumerable in ....
Introduction
The strategy design pattern is a useful pattern for pulling out frequently changing pieces of code and encapsulating them within individual classes. The strategy pattern allows us to reference these new classes in a loosely-coupled fashion, without directly referencing the concrete implementations. This gives us the powerful ability of choosing concrete classes dynamically at runtime, instead of hard-wiring them during code design. This article will show an example usage of the strategy design pattern in creating a basic RPG-style adventure game simulator. The idea for the simulator comes from the popular book Head First Design Patterns by O'Reilly.
Game Design
In this particular game design, we will have specific types of characters and weapons. This directly leads to two basic classes: Character and Weapon. All characters will inherit from an abstract Character class, which w ....
Introduction
With the release of Visual Studio 2008, Microsoft is working on including an add-on for C# ASP .NET web application developers to include the Model view Controller (MVC) design pattern within their software architecture. While one of the add-on's core purposes is to enhance URL functionality in a web application by enabling a model view controller pattern and design structure, the MVC design pattern itself, can be a powerful tool in your C# ASP .NET web applications.
What is the Model View Controller Design Pattern?
The Model View Controller (MVC) design pattern lets us pair loosley-coupled Models and Views together. In this manner, we can keep view logic completely separate from model logic. We can then interchange views or models with different classes, effectively changing an ASP .NET web application's functionality with minimal side-effects.
Since this description ....
Introduction
Designing a C# ASP .NET web application which utilizes a database is a common and straight-forward task for developers. The web application accesses various tables, stored procedures, executes SQL script, and retrieves records. Often, developers not familiar with design patterns will use a simple design for making database calls, which relies on calling database functions straight from the user interface. While this certainly works (and provided you close and dispose of all connections when you're done with them), you achieve a far greater amount of flexibility with your C# ASP .NET web application be using a well-defined and loosely-coupled database layer.
Why Do I Need a Database Layer Anyway?
When creating software for clients, even the beginner developer recognizes the frequency of change. Requirements change, user interface pieces change, platforms change, and databases ch ....
Introduction
The Memento design pattern is a useful pattern in C# ASP .NET for saving the state of an object for retrieval at a later time. A common example of the Memento pattern would be the Undo command of various programs. With the Undo command, the current state information for the task at hand is saved (such as in a Memento). The user may continue modifying data. Upon invoking the Undo command, the state of the data is restored back to its previous state (as stored within the Memento). This article describes how to implement the Memento design pattern in a C# ASP .NET web application. Specifically, this version of the Memento pattern will allow saving multiple types of class states within a single memento object.
Why Not Just Code it the Basic Way?
If you're familiar with implementing state-saving functionality, such as the Undo command, in C# ASP .NET web applications, you may be have ....
Introduction
Stored procedures provide a powerful extension to C# ASP .NET by allowing us to move large portions of data manipulation logic to the database server. Stored procedures are optimized to process data and their associated logic faster than the application layer and are therefore the preferred layer for database logic processing in .NET applications. While stored procedures can be designed to accept many different kinds of parameters as input, it's only a matter of time before you have a need to pass a C# .NET array or collection as an input parameter.
This article explains a simple method for passing an array from your C# ASP .NET application to an MSSQL stored procedure by using a bit of dyanmic SQL.
MSSQL Limitations and Arrays
MSSQL is a favorite database platform for C# ASP .NET developers. For the most part, MSSQL has everything you need for your application. However, o ....
Introduction
There are several different kinds of queues available in the C# ASP .NET framework with the most popular one being the standard Queue collection object. While these collections are easy to work with and fairly robust they are still stored in memory and therefore temporary. Often, in enterprise application design, more stringent means of managing and storing temporary data are required.
In the case of receiving timely data to be processed, using a queue in your software design makes sense. When the data needs to be guaranteed for delivery and protected from loss, the Microsoft Message Queue MSMQ provides a scalable easy solution.
At its core, Microsoft Message Queue MSMQ is a queue collection with a persistent storage backing. This means that data sent to the queue is automatically persisted within an internal Windows database. The MSMQ is also thread-safe, which means a multi-threaded C# ASP .NET application may safely send and receive me ....
Introduction
XML (extensible markup language) is a popular format of data for importing and exporting between different applications designed using different programming languages. Since XML uses a standardized format of data, applications can easily parse the XML data to pull out specific fields, blocks, and even write their own XML files. XML is especially useful as a protocol for communicating over the Internet with applications (ie. SOAP). Given the flexibility of XML, it's only a matter of time before your own C# ASP .NET web application may need the ability to import or export XML data to another application.
Distorted HTML
At a first glance, XML looks just like a web page in HTML. You can easily recognize beginning and ending tags. Brackets enclose each element's name. The document usually has a header tag and a final closing tag. This makes using XML in a C# ASP .NET web appl ....
Introduction
As software becomes more complex, the ability to design a modular and re-usable architecture into your software becomes increasingly important. Using the programming concept of generics with interfaces, included in C# ASP .NET 2.0, software developers can abstract algorithms and classes into individual class libraries. The libraries can be accessed, in a generic fashion, from the main software. The key to this process relies on using interface design patterns and .NET reflection.
What's a Generic?
.NET generics can cover several related topics. The common usage of generics is specifying templated object names instead of concrete ones, which lets you pass multiple types to a function rather than only the concrete form. However, in the example listed below, we will be focusing on using generics and reflection with a class library interface architecture. This is becoming a pop ....
Introduction
Similar in nature to the Chain of Responsibility design pattern, the Observer pattern allows linking of several listener classes to a subject class. When a change or event occurs within the subject class, all listeners are made aware of the event and may take action. This essentially creates a one-to-many relationship between the subject and listeners and can be a powerful tool when designing your software with C#.
Differences Between the Chain of Responsiblity and the Observer
The Chain of Responsibility pattern and the Observer pattern are similar in that they both provide a means of allowing multiple classes to handle an event. The Chain of Responsibility typically passes the event down the chain and once the event is handled, the chain ends. This results in a single class acting upon the event. In contrast, the Observer pattern passes the event to all listeners in the chain, wh ....
Introduction
A powerful design pattern geared towards handling an event is the Chain of Responsbility design pattern. This pattern helps decouple related algorithms in C# ASP .NET and can help your software become more scalable and easier to control.
In general, the Chain of Responsbility design pattern allows you to link together a serious of classes or algorithms in a hierarchy and pass a command (preferably a Command pattern object) into the mix to get handled by one of the members of the chain. One of the benefits of this design pattern is, not having to know the details of the members in the chain. You simply pass the command into the chain. Each class will attempt to handle the request until all classes have been used. While it is possible for a request to go unhandled, this is a powerful design pattern when used appropriately.
Two Ways to Make a Chain
As with all first prog ....
Introduction
The Command Object design pattern can be a powerful tool to use in development of C# ASP .NET web applications. The Command design pattern brings object oriented design to an otherwise non-object oriented piece of data - a command.
It is common to create classes and functions which operate by accepting a command to perform. The command may be a simple string of text or a globally defined integer. In both cases, this command is typically acted upon and then discarded. By wrapping a basic command within a Command Object design pattern, .NET applications can take advantage of the power to perform additional processing on the Command object, log commands, add additional parameters, and much more.
What's Wrong with an Integer Command?
The basic method for issuing a command to a class or function is by assigning a global unique integer to be a dedicated command message. The functi ....
Introduction
Microsoft has recently released the beta version of Silverlight. For those unfamiliar with what Silverlight is, it is essentially a plug-in technology to create web pages and web applications that look much closer to desktop applications. It appears to combine the best of AJAX, DHTML, and Flash/applet technologies by providing stunning visual graphics, animations, programmability, and .NET integration that is compatible with many different web browsers. In a nutshell, it runs .NET in your web browser.
Silverlight is expected to include its own SDK of built-in graphical controls (buttons, drop-down lists, grids, etc). However, this article touches the very beginning of using Silverlight with standard HTML controls; using it more as a replacement for Ajax and DHTML to enhance a standard web page, rather than taking over the entire HTML screen with animated graphics.
Fading an HTML Form ....
Introduction
Developing software can quickly become a complicated process, with lists of funtions, procedures, loops, and repetitive code. Understanding theories of design patterns and implementing them, when neccessary, can help simplify a software's design.
Design patterns have been around for many years, but have recently began gaining popularity due, in part, to Microsoft's promotion of design patterns with the C# .NET framework. If you take a look throughout the .NET framework, you'll recognize many design patterns already existing. In fact, you use them every day in your C# ASP .NET coding, probably without realizing it.
For those who are new to design patterns, the Strategy pattern can be a very handy tool in your C# ASP .NET software design. To describe how to implement the Strategy design pattern, we'll start with the typical "Hello World" Stratgey design pattern.
What's ....
Introduction
MySQL is a free database included with many web hosting services on linux and Windows platforms. C# ASP .NET developers, using a MySQL database back-end, may notice an unnecessarily large list of sleeping connections that remain online in MySqlAdministrator. This can cause wasteful use of memory on the server, degrade performance, and ultimately, create an error in your C# .NET web application. For example, if you go over the limit set by the database administrator for number of connections, your application will receive a "Too Many Connections" error in MySQL. This can cause your application to fail to display data, fail to load pages, or just freeze up on users viewing the .NET site.
Too Many MySQL Connections
Open MySqlAdministrator, click on the Server Connections link, and view the active Threads. Web-based ASP .NET applications seem to incorrectly ha ....
Introduction
If you're creating a web application using C# ASP .NET, you will more than likely be using one of the three top database engines MySQL, MSSQL (Microsoft SQL Server), or Oracle to store your online data. From the developer's view, all three databases are virtually the same. You use the same generic framework calls to connect, read, and write data. While it is more common to use Microsoft's MSSQL Server with a .NET application, a large number of web hosts offer the free MySQL database. Therefore, connecting to a MySQL database from C# ASP .NET is an important task and is actually quite easy to do.
Using MySQL with C# ASP .NET
MySQL is a free database and is used very heavily by the linux developers usually when programming with Perl, CGI, or Ruby on Rails. Because of this, MySQL is, for the most part, catered and optimized directly towards the linux developing platform. However, using MySQL from a Windows web application is also supported a ....
Introduction
An RSS feed is really just a fancy term for an XML file, specifically used to re-distribute web content to aggregators. The most commonly used form of an RSS feed comes from blogs, which are constantly increasing in popularity. Combine the interest in blogs with the major web browsers' ability to now aggregate RSS feeds, and you have a very prominent reason to start creating RSS feeds in your C# ASP .NET web application.
Atom vs RSS
There are actually two types of popular feeds, Atom and RSS. Atom feeds are a more reader-friendly format of XML, and typically display in the web browser in a readable format by simply navigating to the feed.xml URL. RSS feeds, on the other hand, are meant as a more stripped-down version of XML, more easily parsed by aggregators. When viewing an RSS XML feed in your web browser, you will see a list of data tree branches, where you can shrink and expand the XML sections. Internet Explorer 7.0 and Firefox have ....
Introduction
One of the most common functions to perform in Active Directory from a desktop application or C# ASP .NET application is resetting user passwords. Due to the security features of Windows, resetting a password can be a little tricker than you think. After throwing in the security features of IIS and Windows Server, changing passwords from a web application seems almost impossible. However, by following a few important guidelines, you can have your web application easily resetting user passwords in Active Directory.
Note, if you are not yet familiar with connecting to Active Directory in C# .NET, please read our article on Using Active Directory with C# .NET.
Resetting a Password vs. Changing a Password
Active Directory makes a distinct difference between resetting a user's password and changing it.
Resetting a user's password is an administrative function and does n ....
Introduction
Recently, an error occured on a PC with both Visual Studio .NET 2003 and Visual Studio 2005 installed, where new forms could no longer be added to a web project and new projects could not longer be created in VS2003. Upon trying to perform either task, an error message would display stating: "VC Package not available or not registered".
VC Package not available or not registered
Microsoft's web site offers a solution which involves using the Visual Studio 2003 installation CD-ROM and issuing a repair via the control panel. They state the error occurs because the Windows Installer is not registering the TLB and DLL files as they already exist. Issuing a repair re-registers the proper DLL files needed for Visual Studio 2003 to run properly. Microsoft states the steps to correct this are as follows:
Microsoft's Solution
1 ....