Wednesday, February 22, 2012

Simple JSON Example with ASP.NET MVC

JavaScript Object Notation (JSON) is highly used in today’s communication. The main reason is that it does not depend on the programming languages that you use for programming. In simple terms, a JSON object that is returned by a .NET application can be easily read by a Java Application. The only requirement is a particular URL that returns a single or many JSON objects.

Sunday, February 19, 2012

Forms Authentication in ASP.NET

ASP.NET provides you a greater set of capabilities for working with a proper authentication. This is made available with the Membership Provider in it. Membership provider provides rich set of features including adding new users and assigning them specific roles.
By default, once you create an ASP.NET Application (Not empty application), it provides the capability of registering the users and sign-in them. But, how does this work, where are these registration data are stored? As soon as you create an application, just check the folder structure by browsing it through Windows Explorer. (In Visual Studio: Right-click on Application->Open Folder in Windows Explorer) Go inside the App_Data folder and you will find nothing inside in it.

Friday, February 10, 2012

Partial Views in ASP.NET MVC 3

Generally, the coding that we type in the .cshtml or .vbhtml file in a MVC 3 view is rendered through a view engine. Before MVC 3 come into action, ASPX was the View engine used to render the content. MVC 3 introduces a new view engine named Razor. Razor is an effective rendering engine that is introduced with ASP.NET MVC 3. It has simplified syntax along with the easy and cool capabilities provided for the developer to use with. It is easy to use and will not get complicated with the syntax that was available in ASPX View engine.
A much descriptive article on Razor syntax is available at the MSDN.
If you create a View in ASP.NET MVC, it will allow you to create one of the CRUD operations that you would like to have. How are we going to add another operation of the same entity or another in the same View. There are 2 ways that it can be done. We can add a User Control or a Partial View. Both looks like same for a particular extent. User controls have an implementation of events whereas partial views do not.
Creating a Partial View is not that big thing. You just need to try adding a View by right-clicking on the sub folder under the Views folder. Then the Add View window will open. It is advised that the partial views must start with “_” prefix. It makes it easy to identify that as a partial view. Then click the checkbox in front of the Create as a partial view. Since I do have created a model class in my project, I can select it as the model. The way how Model can be modeled is described in a previous article.
Then the partial view will be created. Now it’s time to add it into a View. Just go to the view that you would like to add the partial view and type,
1
@Html.Partial("_Index")
Then the content in the created partial view will appear in the View where it is defined to be located. There are some minor issues when having two forms in both partial view and the View. For example adding the User and adding aProduct in the same. Lets discuss more about Partial views and the ways how it can be done in an upcoming article.

Connecting Windows Phone to Database using WCF Services

Windows Phone is a fantastic creation of the decade. The capabilities that it provides with the Mango update are really cool. One solution of a person who would need storage in Windows Phone application is either to choose the Isolated Storage or connect to an external service with a service provider like Windows Communication Foundation. If you try connecting a database to the mobile app in Android or iPhone, it will take hours for you to create the connection and get it connected. One common method in Android is to use JSON objects, which will take a lot of time.
In windows phone, it can connect with a running WCF service(may be on the web) by simply adding a service reference. This is quite simple.

Thursday, February 9, 2012

Creating a basic ASP.NET MVC Application-Part II

In the previous article, Creating a basic ASP.NET MVC Application-Part I we discussed about creating a User Interface to a Model defined as Student. Then we build and run the application. Going back to the application, The Controller named StudentController calls the Index method so, the Index.cshtml of the Student sub-folder in the Views folder will be deployed. In the Index.cshtml view, we do have referred the Student Model in the Models folder.
Now we are going to perform a Database insert operation. First create a Database that matches the data types described in the Student class of the Models folder. The Database insertion operation must happen in the StudentController.

Wednesday, February 8, 2012

Creating a basic ASP.NET MVC Application-Part I

As I said in the previous article Getting Started with ASP.NET MVC 3, Models implements the logic of data domain of an application. It defines the way how the data should interact with the users of the system. In another way, ASP.NET models assure that the data are in the appropriate format before it gets inserted or retrieved from a database. It does not mean that the Databases are the only interacting component of the model. Users can simply create data objects as well. The beauty of MVC 3 is that it facilitates the Model to be modeled with Entity Framework. So it can be done within a few clicks.

Getting Started with ASP.NET MVC 3

As all of you know, ASP.NET is one of the most powerful and secured technologies for web related development. It has a higher penetration as well as an increasing demand towards it. Higher security capabilities, ease of development and maintenance, flexibility and scalability are some of the reasons for lot of reputed companies in the world to selecting ASP.NET for their solutions. Model-View-Controller design pattern is one of the highly used design patterns in today’s world. The simplest basic behind this is dividing the application in to three components named Model,View and Controller. ASP.NET MVC Framework is a framework that supports the development based on MVC design pattern with a lot more enhanced set of features. It provides the developer the capabilities of developing a web application with a less amount of coding that needed to be done manually.