ASPHostCentral.com ASP.NET MVC Hosting BLOG

All about ASP.NET MVC 4.0 Hosting, ASP.NET MVC 3.0 Hosting and ASP.NET MVC Hosting articles

WebMatrix 3 Web Hosting

clock April 28, 2013 16:36 by author Administrator

ASPHostCentral.com offers the latest WebMatrix 3 hosting service to all our new and existing customers.           

You can always start with our Standard Plan (from @$4.49/month) to deploy WebMatrix 3 applications to our server. Should your requirement changes in the future, you can always request for an upgrade without causing any downtime. Remember, everything is just one-click away from your mouse! So, why wait longer?
Please register your interest here.

What is WebMatrix?

WebMatrix is a free, lightweight, cloud-connected web development tool.

Designed for Top Languages

Create websites using our ASP.NET, PHP, Node.js, or HTML5 templates, and take advantage of the latest web standards, emerging standards(CSS3, HTML5), and popular JavaScript libraries such as JQuery

Your Companion for the Cloud

When you create local projects, you’ll be able to instantly get a companion website in Windows Azure without ever leaving WebMatrix. Using the Publish button, you can easily keep these sites in sync and save your changes to the cloud

Source Control with Git

Plug into GitHub, CodePlex, and Team Foundation Service to start sharing your code with the world. Whether you’re a newcomer to git, or a seasoned pro, you’ll find all of the features you would expect in a powerful but easy to use too

Remote Site Editing

Simply open your remote sites, make changes, and hit Save. The lightweight performance and full editing capability (including intellisense) make it feels like you are editing a local site!

Optimized for Open Source

Install popular web apps with a few clicks, customize them easily with app-specific code completion, and publish them quickly to the web.

Designed for Mobile

Optimize your websites for mobile browsing with built-in templates, device emulators and code completion for JQuery mobile

Source Control with TFS

Team Foundation Service is Microsoft’s hot new source control service in the cloud. WebMatrix 3 makes it simple and fun to work with your code using TFS for any project in the cloud, or on site.

Extended by the Community

Want an iPhone simulator or power tools for Node.js? Find extensions that add even more functionality to WebMatrix, or create your own


Currently rated 1.7 by 69 people

  • Currently 1.68116/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


ASPHostCentral.com offers Windows and ASP.NET Hosting on Singapore (Asia) Server

clock October 14, 2012 17:23 by author Administrator

ASPHostCentral.com has a strong commitment to provide global access and service to all our new and existing customers. To meet this commitment, ASPHostCentral.com proudly launches the latest and newest data center located in Singapore (Asia). Starting from 15th Oct 2012, ASPHostCentral.com opens an opportunity to everyone to host their websites on our Singapore Data Center.

Our Singapore data center is supported with Multiple connections to major Internet backbone carriers via SingTel, SingNet, NTT Communication, Deutsche Telekom AG, Hurricane Electric and PCCW with OC-12 connections using BGP-4 routing protocol. This Singapore Data Center hosting is suitable to anyone who plans to do an online business in Asia. If you are targeting Asian market or if you like to mirror your US-based or Europe-based website or if you are located in Asia and want to host your site in Asia data center, our Singapore server is certainly suitable for your needs

Our Singapore Data Center Network Advantages

- Multiple and geographically redundant dedicated connections to Tier-1 Internet backbones from the largest ISPs in South East Asia, Europe and USA

- Multiple connections to major Internet backbone carriers via SingTel, SingNet, NTT Communication, Deutsche Telekom AG, Hurricane Electric and PCCW with OC-12 connections using BGP-4 routing protocol

- Peering relationships are monitored and maintained 24x7x365 and upgraded as needed

- All Data Centers deploy Border Gateway Protocol (BGP4 Routing Protocol) that enables a multi-homed provider to setup a truly redundant network. By connecting to multiple backbones, ASPHostCentral.com data center distributes data out quickly in the shortest possible path. In the even of a failure in one circuit, our network automatically re-routes data to another backbone, ensuring uptime and redundancy for our customers


Singapore (Asia) Windows Hosting with ASPHostCentral.com

- New Customer - You can start from as low as $6.99/month to start hosting your website on our newest Singapore Server. If you do not have a domain name, please do not worry as we will give you one FREE domain name (worth $14.99/year) if you register for any of our hosting plans for 12 months service(*). We will do our best to help you create your first web presence on the internet and we will continuously support the growth of your business.
- Existing Customer - For all existing customers, a migration to a server located on our Singapore data center is required and hence, a migration and setup fee apply. Starting from 15th Oct 2012, we have offered Windows Server located on our Singapore data center and for clients who registered before this date is required to pay this setup fee. Thank you.

Currently rated 1.4 by 35 people

  • Currently 1.428571/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Press Release - ASPHostCentral.com now offers IIS 8 Hosting on Windows Server 2012

clock September 26, 2012 19:28 by author Administrator

ASPHostCentral.com, the premier Windows and ASP.NET Hosting provider, proudly announces the availability of IIS8 Hosting on our most advanced Windows 2012 hosting platform. ASPHostCentral.com supports .NET Framework 4.5, so you can run apps built with ASP.NET 4.5, Visual Studio 2012, and Visual Studio Express 2012. We also support ASP.NET MVC 4, Silverlight 5, One-Click Publish and WebMatrix Hosting!

This IIS 8 service is bundled with our newest Windows Server 2012. Within Windows Server® 2012 you will find exciting innovations in areas of virtualization, networking, storage, user experience as well as an improved integration with Windows PowerShell® which takes scripting to a whole new level. This is quite possibly the most significant release of Windows Server® ever.

What is new in IIS 8.0 for Windows Server® 2012?

- FTP Logon Attempt Restrictions
- CPU Throttling: Sand-box for sites and applications
- Application Initialization Module
- Centralized management of SSL certificates
- Server Name Indication (SNI): SSL Scalability
- Use ASP.NET 3.5 and 4.5
- ASP.NET Configuration Management
- Dynamic IP Address Restrictions
- Multicore Scaling on NUMA hardware

Our IIS 8  Hosting Packages

Our IIS 8 Windows Hosting Package starts from as low as $4.49/month only and the package has included the following features:

- Windows Server 2012
- World Class Control Panel
- ASP.NET 4.5 and ASP.NET MVC 4
- Silverlight 5
- WCF RIA Service
- VS 2012
- VS Lightswitch
- WebMatrix
- One-click publish
- SQL 2012

For more information, please contact ASPHostCentral.com.

Currently rated 2.0 by 20 people

  • Currently 2/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


VS 2012 Hosting :: ASP.NET Web Forms 4.5 new features in Visual Studio 2012

clock September 24, 2012 17:13 by author Administrator

This post discusses about ASP.NET Web Forms 4.5 features, Web Forms in 4.5 allows you to build dynamic web sites quickly and easily. Web Forms generates much cleaner code on client-side with Unobtrusive Validation in this version. You can also build data-centric applications easily with data-binding features.

If you like to host your ASP.NET Web Forms 4.5, you can have a look at
asphostcentral.com

Typical Web Form which contains more fields and validation controls can generate more code on client-side. When you run this typical form in browser then you can see the page size as below



The reason for this size is because client-side validation is enabled. If you change Unobtrusive validation mode in page load to web forms then you can see the difference.



Now re-compile your application and run the page the result is as shown below, Now page size is much smaller than before



Strongly typed Data Controls

Take a typical Search Form which shows the results in list view. Inside list view you have item template which is having multiple calls to the EVAL expression as shown below



The above method is the standard way of doing data-binding in web forms. You optimize the above using strongly typed data controls.



You can set the Item Type property of List View to the type that you actually data-binding to as shown below



Now you can member variables in place of Eval expressions, member variables are now typed and you will get an Intel license on item class

Model Binding

You may be familiar with Model Binding in ASP.NET MVC, The typical code which you might write in web forms to bind the results in web forms as below



The above code talking to the data base by building a query which does a case insensitive search then it coverts into list binds the results to list view. Let us re-write the above code using Model-Binding



Now there is no page load and click-handler, The above code is not directly interacting with the page. You can populate the formTerm and qsTerm variables using attributes Control and QueryString in model-binding.

The return result of GetResults method is IQueryable. Because the result is of type IQueryable the control has the ability to modify this before it is rendering it to the page. You can use this in sorting and paging. You can specify the same in markup.

Advantage of using Model Binding


As the code is not directly interacting with the page, you can fairly easily unit test the method or even move it to the completely different class.

Support for OpenID in OAuth Logins



The AuthConfig.cs file is standard in all new projects that created in ASP.NET 4.5 in Visual Studio 2012. You can see there are number of external services code is commented out and it is ready to use by putting your custom application credentials.

Now you can use external services to login to the application.

These are the features which you can try out in Visual Studio 2012.

        

Currently rated 2.1 by 24 people

  • Currently 2.083333/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


ASPHostCentral.com now supports SharePoint 2013 Hosting

clock September 13, 2012 17:51 by author Administrator

ASPHostCentral.com, the leader in ASP.NET and Windows Hosting Provider, proudly announces that we have supported the latest SharePoint 2013 Hosting

We offer this newest
SharePoint 2013 Hosting Package from just $15.99/month. Our SharePoint 2013 hosting plan comes with a list of complete features, such as:

- Massive Document Storage Space
- Massive Bandwidth
- Unlimited Number of SharePoint Users / Accounts
- SharePoint Designer 2013
- Support Third-Party (Custom) Web Parts)
- Support International Language Packs
- Support SSL for higher data integrity
- Support Anonymous, Public-Facing Access

To make our SharePoint 2013 even more complete, we have added extra features free of charge to the package. These features are:

- .NET 4.5 and ASP.NET MVC 4.0 Framework
- Silverlight 5.0
- SQL Server 2012
- Entity Framework (EF)
- WebMatrix and WebDeploy
- Windows 2012 Hosting
- WCF RIA Service
- World Class Control Panel
- 24/7 Support
- 99.9% Uptime Guarantee
- Choice of US or European Data Center
- 30-days Money Back Guarantee

SharePoint 2013 is the new way to work together. A simplified user experience helps you organize, sync and share all your content. New social capabilities make it easy to share ideas, keep track of what your colleagues are working on, and discover experts you never knew existed.

Putting a SharePoint team website in place for your business is a fast, cost-effective way to facilitate team communication while creating a professional looking website. Team sites based on Windows SharePoint Services are useful right out of the box. You can customize your site, changing its appearance and adding functionalities without using other applications or doing any programming

Obviously, we still support the SharePoint 2010 Hosting on our Windows Server environment.

Currently rated 1.4 by 12 people

  • Currently 1.416667/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


.NET MVC 4.0 Hosting :: ASP.NET MVC 4 and working with HTML5 Chart Helper Extension

clock September 10, 2012 15:41 by author Administrator

With the introduction of ASP.NET MVC, the traditional ‘Control’ model of GUI component development went away. Instead it was replaced with the more Web 2.0 style JavaScript and jQuery plugin extensibility model. Nevertheless, adding incremental features to existing HTML components was always required and towards this end Microsoft introduced the HtmlHelper and helper extensions. Helper extensions are .NET extension methods that return a string. Typically, this string is formatted HTML content.

In our sample today we create an extension that renders a bar chart on HTML5 Canvas. It can be bound to a data source from the server side or be assigned data source from the client side.

Building a Html Helper Extension

Html Helper extensions are easy to build. Just follow the steps below to create our helper skeleton.

Step 1: We start with an MVC project and pick the Blank template.

Note we could pick a class library project template too and add package references as follows (via the Nuget package manager as follows)

a. PM> install-package Microsoft.AspNet.Mvc
b. Add reference to System.Web.dll from the ‘Add References’ dialog for the project

Step 2: Add a static class called ChartExtensions. Extension methods, by design, have to be defined in Static classes.

Step 3: Next add a static method Chart whose first parameters is this HtmlHelper and subsequent parameters are values required for rendering the chart.



a. The dataSource is a list of integer arrays. For the example we have assumed a two dimensional array would be provided as a data source. We can make it more sophisticated by making it an array of objects and binding to different properties of the object.
b. xTitle: The text to be displayed on the x-axis.
c. yTitle: The text to be displayed on the y-axis.

Step 4: Next we setup two methods, one to convert the dataSource to JSON and the other to generate the required HTML.



a. The GetDataSourceFromIntArray method uses the System.Web.Helpers’ Json static class to convert the input data source into a Json String. This string is assigned to a variable called arrDataSource and the whole string is returned.
b. The SetupHtml method implements the rendering logic

Step 5: Using TagBuilder to build the Html: ASP.NET provides us with the TagBuilder class that has helper methods to help create HTML elements easily. We use the TagBuilder to create our HTML layout as follows

<div>
<canvas …> … </canvas>
<script …> … </script>
<noscript> … </noscript>
</div>

The actual code is as follows


a. As seen above, the TagBuilder object has an Attributes collection to which we can add the HTML attributes we need. To set text between the opening tag and closing tag, we use the SetInnerText. However unlike an XmlTextWriter, we can’t nest tags. To nest tags we simply assign the string representation of the TagBuilder to the InnerHtml of the parent TagBuilder. So the ‘container’ Tag Builder has the <div> that encapsulates the Canvas and the Script tags.
b. We have created a 400x600 canvas area. The chartName parameter is used for the id of the canvas element.
c. For now we have an empty SetupScript method. This method will eventually build the JavaScript required to render the bar graph.
d. The <noscript> tag holds the message to display when JavaScript is not enabled on the browser.
e. Point to note is the HtmlString object that is returned. The HtmlString is a special object that indicates to the Razor view engine that it should not Html Encode this string any further. If we use string instead of HtmlString, the Razor engine automatically Html Encodes the string and we see the markup as text instead of rendered Html.

Step 6: The SetupScript method: The setup script method has the JavaScript that actually renders the chart on the canvas. The original code is borrowed (with permission) from this project. A demo for it is available here. We have to make the following changes so that it accepts any data source instead of the fixed data source assigned to it in the demo. We have also updated the code to use the strings passed in for x-axis and y-axis labels. Beyond this the animation and rendering code is pretty much the same.

a. The variable initialization change

Earlier we had a hard-coded array of strings that was rendered on the canvas. Now we have the Json string that is created from the data source that was passed to the helper.
b. Changes to the barChart() method to set data source on the client side.

In the barChart method we earlier had no parameters and the elementId was hard-coded, now we use the value that’s passed into the helper.
We also pass a data parameter that is assigned to the data source of the graph.
c. Changes in drawMarkers() method to use the values passed into the helper for the x-axis and y-axis label

d. Changes to handle two-dimensional array of points instead of one-dimensional array of comma separated strings.


In the original code, the data source is an array of strings. Each element in the array has two comma separated values, represent the year (at index-0) and number of hits (at index-1). We have updated our data source to be a two-dimensional array and hence we don’t need to do a string split to get the value. We directly access the value using appropriate indexes. This change is at three places in the code. One of them is shown above.

With these changes in place our Chart, HtmlHelper is ready to be tested in an ASP.NET Web Application

Integrating the Custom Helper in a MVC Web Application

With our Helper all set, we add an MVC Web Application to our solution and call it DotNetCurry.HtmlHelpers.WebHarness. We use the Internet template that gives us a default Index.cshtml to put our Helper in. The following steps guide us through the integration effort

Step 1: Add Reference to the HtmlHelper project.

Step 2: Add a Model class in the Models folder.


This is our view model that will hold the data to be rendered in the Graph.

Step 3: Update the HomeController to create and pass sample data model.



As seen above, we create an instance of our ViewModel class and add some test data into it. We pass this data on to the Index view, where the HtmlHelper will use it.

Step 4: Update the Index.cshtml markup to use the helper


The changes in Index.cshtml highlighted above, from top to bottom are as follows

a. Declare the model to be used in the page.
b. Add using to include the custom HtmlHelper
c. Added the HtmlForm inside which we use our Chart Helper extension. We give it an id=’sampleChart’, pass it the Model.Data and provide the labels for the x and y axes.
d. Finally in the jQuery document ready function, we initialize the chart by calling the barChart() method.
e. Our final effort looks as follows.



To change the graph change the data set coming from the controller.

That brings us to the end of this tutorial. We round off with some of the improvements possible.

Possible Improvements

1. Update the script to be able to bind to any Json object.
2. Use jQuery plugin syntax so that more than one helper can be created per page.
3. Allow more flexibility like passing parameters for bar colors, size of chart etc.
4. Allow multiple data sources to show comparison side by side.
5. Add more chart types like Pie etc.

Conclusion

Though they sound esoteric HtmlHelper extensions is a rather simple mechanism to inject rich functionality in a componentized way in ASP.NET MVC applications. We converted an existing HTML5 chart, originally created using plain HTML5 and JavaScript into a Chart HtmlHelper with very little code. For large projects, HtmlHelpers are a neat way to encapsulate small pieces of re-usable UI functionality.

Currently rated 1.9 by 18 people

  • Currently 1.944445/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Windows Server 2012 Hosting - ASPHostCentral.com

clock August 29, 2012 17:16 by author Administrator

ASPHostCentral.com
 proudly supports the latest Windows Server 2012 on all our newest servers. You can certainly run and deploy your project on our highly-secured Windows Server 2012 environment instantly! 



Windows Server 2012 Essentials 

An ideal server for small businesses, Windows Server 2012 Essentials (formerly known as Windows Small Business Server Essentials) provides a powerful and flexible solution that helps protect your business data while allowing you to access the information you need from virtually anywhere using almost any device. Windows Server 2012 Essentials supports the applications you need to run your business and also helps you to quickly connect to additional cloud-based applications and services to extend your server’s functionality. 

Benefits 

Small organizations want to focus on their core business, not on managing an IT infrastructure. Windows Server 2012 Essentials can help to minimize the time, effort, and money that you spend on IT. 

Windows Server 2012 Essentials provides you and your employees highly secure access to your company’s data and applications so that you can be productive—even when you’re not in the office—and offers you the flexibility to make technology decisions based on your individual business needs. 

With Windows Server 2012 Essentials, you can: 

- Protect and secure your business. The server’s intuitive user experience and powerful data protection features, such as full client PC backup, can simplify your life and help you focus on your core business.
- Access your resources from virtually everywhere using almost any device. Empower your remote workforce with the freedom to work where and when they choose with an Internet connection and web browser.
- Leverage the power and flexibility of cloud-based services on your terms. Windows Server 2012 Essentials helps you run your business operations, be more efficient, and enjoy competitive advantages by making it easier than ever to use and manage cloud-based applications and services, on-premise applications, or a combination of both. 

Currently rated 2.4 by 19 people

  • Currently 2.421053/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


.NET MVC 4 Hosting :: New Things to Learn in ASP.NET MVC 4

clock March 27, 2012 15:59 by author Administrator

Introduction

MVC4 is really trying to break new ground in helping developers get to market more quickly and with a product that adheres to the emerging standards of today. A tough thing to ask of any technology, to be sure, but it's making some decent strides in the right direction.

Already the tutorials and blogs posts are popping up quicker than mushrooms on the midden heap. We highlight a few here that you definitely shouldn't miss which deal with key upcoming features...

ASP.NET MVC  4 Hosting

If you are looking for a QUALITY, AFFORDABLE host that supports
ASP.NET MVC 4 Hosting, you can take a look at ASPHostCentral.com



ASP.NET MVC 4 Overview - Part 2

Jon Galloway goes into some significant detail here about some of the changes coming our way in the new version. He talks about the new default templates that come out of the box and the reasoning behind them.

He also talks about the new adaptive rendering taking advantage of CSS media queries and the usage of the viewport meta tag to help improve the mobile user experience. Overall a solid post that will stand the test of time. Check it out...


ASP.NET MVC 4 Bundling and Minification

Bundling and Minification of assets have to be two of the most tedious things to setup on a new web project. In this excellent post, David Hayden goes through exactly what you need to do to make the process as seamless as possible in MVC4.

Don't make the mistake of leaving this to the end of the project. You'll have deployment nightmares you didn't dream of and you'll be kicking yourself for not smoothing out the wrinkles. Do it early, and you'll thank yourself everyday for that small mercy...


Micro ORM Data Mapping with PetaPoco and ASP.NET MVC 4

Getting tired of working with the verbosity of Entity Framework classes and mapping? Well, you're not the only one, and in this quality post, Greg Arroyo takes us for a lap around the track using PetaPoco as your Micro ORM in MVC4.

Micro ORMs really are here to stay, and in some ways, more broadly applicable to web applications of today where everyone is trying to keep things more simple. If you haven't tried one yet, take this opportunity to get clued up on these fantastic tools.


ASP.NET MVC 4 Web API Routes and ApiController

Once again David Hayden masterfully takes us through a key piece of architecture that is going to be very important to anyone who will be working with MVC4. He details what seems to be a very slick piece of integration work between the new Web API framework and MVC4, and he throws in some OData queries for good measure.

It's short and sweet, and just enough to get you going, and whet your appetite for how to architect your solutions around your own APIs, allowing for more decoupled designs with less possible points of failure.


Getting started on your first Single Page Application

As with the introduction of any new method now encompassed in a technology, it's best to start with what comes straight from the horse's mouth. This Walkthrough put together by Brad Severtson gives you a great introduction, and leaves the mind boggling as to the possibilities.

If you've ever wanted to build your own Gmail and specifically wanted to do it with MVC, then go ahead, knock yourself out! (no pun intended)..

Currently rated 1.6 by 106 people

  • Currently 1.556604/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


ASP.NET MVC 4 Hosting :: Entity Frameworks Database Migration and ASP.NET MVC 4

clock March 21, 2012 16:30 by author Administrator

ASP.NET MVC 4 was released in beta by the Microsoft ASP.NET MVC Developer Team and it comes with a number of really cool features: Bundling and Minification Support of CSS and JavaScript, Database Migrations using Entity Framework 4.3, Web APIs, Mobile Web with support for jQuery Mobile, Real Time Communication via SignalR, and Asynchronous Support. The Database Migrations using Entity Framework Code-First is really cool and is very much like Rails where you can change your code and then via Package Manager add migrations and update your database as your code evolves. Because the EF Migration Files and Configuration get added to your Visual Studio Solution, all the database migration changes get added to source code.

If you are looking for a quality ASP.NET MVC 4 Hosting provider, please have a look at ASPHostCentral.com


   

ASP.NET MVC 4 and Entity Framework Code-First

ASP.NET MVC support for EF Code-First has been there since ASP.NET MVC 3. To jump start playing with Database Migrations start an empty ASP.NET MVC 4 Project and use Package Manager to install or update Entity Framework to the latest version that includes Database Migrations.

Install-Package EntityFramework

Add a simple Product Class that represents a product in your E-Commerce Website. Let's intially make Product simple by just providing an Id and Title to it.

public class Product {
    public int Id { get; set; }
    publis string Title { get; set; }
}


Run the Add Controller Recipe in ASP.NET MVC 4 to add a Products Controller that uses Entity Framework to read/write to the Database of your E-Commerce Website.



Once the Add Controller Recipe is finished you will have a working ASP.NET MVC 4 Website that reads and writes products to the Database using Entity Framework. The ProductsController was created along with all actions and views that display, create, update, and delete products.

Enabled Database Migrations to ASP.NET MVC 4

Now we want to enable database migrations to ASP.NET MVC 4 by using the Package Manager Console.

Enable-Migrations

Enabling database migrations creates a new Migrations Folder in your Visual Studio Solution as well as an InitialCreate Target Migration that has both an Up and Down Migration. The Up Migration creates the Products Table while the Down Migration drops the Products Table.

public partial class InitialCreate : DbMigration {
    public override void Up() {
        CreateTable(
            "Products",
                 c => new
                 {
                      Id = c.Int(nullable: false, identity: true),
                      Title = c.String(),
                  })
                  .PrimaryKey(t => t.Id);
         );
     }

     public override void Down() {
          DropTable("Products");
     }
 }


Add New Database Migration to ASP.NET MVC 4 Website

Now let's say we want to add more properties to the Product Class as well as make Title a Required Property and a length of 255 characters.

public class Product {
    public int Id { get; set; }

    [Required,MaxLength(255)]
    public string Title { get; set; }

    public string Description { get; set; }

    public decimal Price { get; set; }
}

One can now add a data migration as well as update the database via the Package Manager Console.

Add-Migration AddDescriptionPriceToProduct
Update-Database


The Add-Migration command creates another file in the Migrations Folder of our ASP.NET MVC 4 Project and the Update-Database command updates the database with the new Description and Price Columns as well as modifies the Title Column to be only 255 characters and not nullable.



If you look at the ASP.NET MVC 4 Database before and after issuing this Database Migration you will notice the effect.



And, of course, the new Database Migration File has the approprite Up and Down Methods.

public partial class AddDescriptionPriceToProduct : DbMigration {
    public override void Up() {
        AddColumn("Products", "Description", c => c.String());
        AddColumn("Products", "Price",
            c => c.Decimal(nullable: false, precision: 18, scale: 2));
        AlterColumn("Products", "Title",
            c => c.String(nullable: false, maxLength: 255));
    }

    public override void Down() {
        AlterColumn("Products", "Title", c => c.String());
        DropColumn("Products", "Price");
        DropColumn("Products", "Description");
    }
}

Conclusions

If you are a Rails Developer moving to ASP.NET MVC 4, you will find the Database Migrations support in Entity Framework a nice addition to the tooling. And, of course, those ASP.NET MVC 4 Developers that love Code-First Development with Entity Framework will love the new Database Migrations support in EF 4.3. Don't forget to check out other ASP.NET MVC 4 Features such as bundling and minification of CSS and JavaScript, Web API's, Asynchronous Support, and the mobile web templates. ASP.NET MVC 4 is still in beta at this point, but it has a go-live license.

Currently rated 1.8 by 26 people

  • Currently 1.846154/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


ASP.NET MVC 4.0 Hosting :: Exciting Features of ASP.NET MVC 4.0 Framework

clock March 15, 2012 15:59 by author Administrator
Not only MVC

First of all I want to make clear that most features aren't MVC-specific features. However, MVC does implement most of them out-of-the-box, while Web Forms needs some more installation and configuration work.

Front-end

Minification

There are some really neat features on the front-end part of MVC 4, first of all there's minification. Minification means that all spaces, enters and comments are removed from your CSS / Javascript files (including coffee, SASS and LESS), and that variable names are replaced with shorter variable names (such as a, b, c, etc.). This means that less data needs to be transferred to the visitors of your website, resulting in a faster page loading time, etc. Probably a feature that any front-end developer will love.

Bundling

Another cool feature that is often mentioned in one sentence with minification is bundling. Bundling means that you can have separate CSS files (e.g. one for your content, one reset style sheet, one for your layout) that are 'bundled' into one CSS file. ASP.NET does this by convention (but it's also configurable), for example: the reset.css will be placed in the bundle first, etc. This means that you only have one request instead of multiple requests, again resulting in a faster page load time.

Mobile web

Much has been done to improve the way MVC 4 behaves on mobile devices. There's now a mobile application project type that creates a nice lay-out that uses JQuery mobile to do all kinds of fancy stuff. MVC 4 also tries to render your lay-out in a mobile compatible way. This means that your elements are properly resized to fit inside the screen of mobile devices. But this is not the only feature, nor is it the most exiting feature. The most important mobile web feature (in my opinion) is the fact that you can now create device specific views. This allows you to create specific views for Windows Phone 7 devices, for Android devices, etc.

Project templates

For those who just want to make a quick prototype there are new project templates that look pretty fancy compared to the old project templates. Below is an overview of the new templates, the left template is the default template when you choose the 'internet application' project type, the second is the 'single page application' type and the third, obviously, the mobile type. The new project types also support AJAX login and OAuth.

Back-end

Web APIs

A very exiting new feature of ASP.NET is the introduction of Web APIs. This is another name for the new controller type, namely the ApiController. The ApiController makes creating an API much easier compared to WCF. Just like the default MVC controllers you can mark methods to be HttpPost methods, HttpGet methods, etc., but there are many new features to this.

The ApiController now allows users to perform queries against the API with OData if the ApiController method returns IQueryable<T>, it's possible to return specific HTTP codes to the consumer of the API, there's improved testability and IoC support, and more features that you will love.

Since the ASP.NET team and the WCF team have been merged, the new ASP.NET Web API wil replace some parts of WCF. This is a good things because the Web API is really easy (and flexible) to work with.

If you want to know more about ASP.NET's Web API I recommend Scott Guthrie's blog post about it.

Async

There was Async support in MVC 3. This meant that you need to have two methods: an Async method and a Completed method. MVC 4 removes the need for two methods and simplifies the way tasks are defined. Below are two examples:

The MVC 3 approach:

public void IndexAsync(string city) {
    AsyncManager.OutstandingOperations.Increment(2);
    NewsService newsService = new NewsService();
    newsService.GetHeadlinesCompleted += (sender, e) =>
    {
        AsyncManager.Parameters["headlines"] = e.Value;
        AsyncManager.OutstandingOperations.Decrement();
    };
    newsService.GetHeadlinesAsync();
     SportsService sportsService = new SportsService();
    sportsService.GetScoresCompleted += (sender, e) =>
    {
        AsyncManager.Parameters["scores"] = e.Value;
        AsyncManager.OutstandingOperations.Decrement();
    };
    sportsService.GetScoresAsync();
}

public ActionResult IndexCompleted(string[] headlines, string[] scores, string[] forecast) {
    return View("Common", new PortalViewModel  {
        NewsHeadlines = headlines,
        SportsScores = scores,
    });
}

The MVC 4 approach:

public async Task<ActionResult> Index(string city) {
    var newsService = new NewsService();
    var sportsService = new SportsService();    

    return View("Common",
        new PortalViewModel {
        NewsHeadlines = await newsService.GetHeadlinesAsync(),
        SportsScores = await sportsService.GetScoresAsync()
    });
}

As you can see the MVC 4 approach is much shorter and much easier, probably leading to more people using asynchronous methods. The code is still compiled into the same intermediate language, it's just syntactic sugar.

Real-time communication

There's also support for WebSockets and a new open source framework called SignalR that allows you to set up a real-time multi-user interactive website in a real easy manner. I highly recommend reading Scott Hanselman's blog post about SignalR and the official SignalR Github project.

Database migrations

The last feature that I wanted to mention is probably the coolest new feature. However, it's rather an Entity Framework feature than an ASP.NET feature. I'm talking about Entity Framework 4.3's new Database Migrations.

What it means is that Entity Framework can generate classes with Execute/Unexecute (actually they are called Up and Down, but I don't think those names really describe what they do), performing any database modifications that you've made. For example: let's say we have an entity called Person. If I wanted to add a property called 'Age' to Person entity, Entity Framework would generate a class for me with two methods: the Up method that adds the Age property to the Person table in the database (or whatever we've mapped the Person entity to) and the Down method that removes the Age property from the Person table. This allows us to rollback any changes, or easily perform updates on the database.

Entity Framework also allows us to generate SQL so we don't have to write change scripts manually any more. Automating the generation of change scripts can significantly reduce the time it takes to deploy your application, allowing the developers to focus on developing new features.

Currently rated 1.9 by 16 people

  • Currently 1.875/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


ASP.NET MVC Hosting

ASPHostCentral is a premier web hosting company where you will find low cost and reliable web hosting. We have supported the latest ASP.NET 4.5 hosting and ASP.NET MVC 4 hosting. We have supported the latest SQL Server 2012 Hosting and Windows Server 2012 Hosting too!


Sign in