Posts

Showing posts from May 8, 2011

ASP.NET MVC Overview

Image
Introduction ASP.NET MVC is one of the methods of developing ASP.NET applications. In this article, we will go through the overview of ASP.NET MVC by creating a simple application. ASP.NET MVC Framework is Microsoft’s Web Application development framework, the other one being traditional webforms framework. MVC or Model View Controller is a design pattern that addresses the separation of concerns(Soc) which is the process of identifying and separating the application into distinct parts like UI, Logic and Data Access. Soc has proven to be useful in the design of web applications. Keeping the view separate from the other parts of the application means that we can easily change the view without affecting the rest of the application. Similarly, if we want to change the main application logic, we just need to change the controller. ASP.NET MVC is an implementation of the MVC design pattern. The framework helps Test Driven Development which is a method of development in which Unit Test Ca

Implement a Cancel button while using Bindings, and send only an object's changes to a WCF service

Take the following scenario: A user of your application opens a customer for editing. They put in a new address. Now they realize they're in the wrong customer entirely and want to cancel their changes. What does your application do? If you're like me, then you are on a mission to keep code behind to an absolute minimum. You have two way bindings setup for everything. You're proud of all the C#/VB code that you  haven't  written in your application. So, your model is already updated. Do you not have a cancel button? Blame the user for the bad experience and tell them not to do that? Or did you add a reload method to your cancel button instead, forcing the application to grab data from a web service or a database? Another possible option might have been to follow MVVM completely and to separate the Model from the ViewModel even on the most basic classes. The ViewModel could then store copies of this data and include methods to move back to the object and to reload data

Send Cookies When Making WCF Service Calls

Image
Introduction This article presents an example on how to send cookies when making WCF service calls. Background Once in a while, you may find that you want to send some information in the form of " Cookies " to the server when making WCF calls. For example, if the WCF service is protected by a " Forms Authentication " mechanism, you will need to send the authentication cookie when making the WCF call to gain the required access to the service. If you are calling a " REST " service using the " WebClient " class, this should not be a difficult task. You can simply work on the " CookieContainer " property of the " HttpWebRequest " class. If you are calling a regular WCF service, and your client proxies are generated by the " Adding service reference " tool in the Visual Studio, the method to send cookies is not so obvious. This article is to present an example on how to send cookies when making WCF calls using the Vis

ASP.net 4.0 Ajax

jQuery Included with Web Forms and MVC The Visual Studio templates for both Web Forms and MVC include the open-source jQuery library. When you create a new website or project, a Scripts folder containing the following 3 files is created: jQuery-1.4.1.js – The human-readable, unminified version of the jQuery library. jQuery-14.1.min.js – The minified version of the jQuery library. jQuery-1.4.1-vsdoc.js – The Intellisense documentation file for the jQuery library. Include the unminified version of jQuery while developing an application. Include the minified version of jQuery for production applications. For example, the following Web Forms page illustrates how you can use jQuery to change the background color of ASP.NET TextBox controls to yellow when they have focus. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="ShowjQuery.aspx.cs" Inherits="ShowjQuery" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//E

ASP.net 4.0 Core Services

ASP.NET 4 introduces a number of features that improve core ASP.NET services such as output caching and session-state storage. Web.config File  Refactoring The  Web.config  file that contains the configuration for a Web application has grown considerably over the past few releases of the .NET Framework as new features have been added, such as Ajax, routing, and integration with IIS 7. This has made it harder to configure or start new Web applications without a tool like Visual Studio. In .the NET Framework 4, the major configuration elements have been moved to the  machine.config  file, and applications now inherit these settings. This allows the  Web.config  file in ASP.NET 4 applications either to be empty or to contain just the following lines, which specify for Visual Studio what version of the framework the application is targeting: <?xml version="1.0"?>   <configuration>    <system.web>     <compilation targetFramework="4.0" />

ASP.NET URL Rewriting with HttpHandler

Most of the time when we start learning something or doing something we get the first question that how does it helps? Or where I can use in the real world? Same thing goes in this technique as well. What are URL rewriting first of all then what is routing engine? Let us see some real issues in our code. A. Case 1 One day you had a URL book marked as Http://abc.com/main/1.aspx. But now it is moved to Http://xyz.com/main/1.aspx, will it work now, no. But as a web site developer or architect how you will manages these kinds of broken links in web sites. B. Case 2 Suppose we have two servers where each server has hosted with 50 pages. But all the links have to be made available for both web sites. How do we handle this situation? C. Case 3 A website restructuring caused all of the Web pages in the /Admin/ directory to be moved to a /finance/Admin/ directory, you would want to use URL rewriting to check if a Web request was intended for a file in the /Admin/ directory. The req