European ASP.NET MVC 4 and MVC 5 Hosting

BLOG about ASP.NET MVC 3, ASP.NET MVC 4, and ASP.NET MVC 5 Hosting and Its Technology - Dedicated to European Windows Hosting Customer

European ASP.NET MVC 4 Hosting - Amsterdam :: How to Upgrade ASP.NET MVC 3 Project to ASP.NET MVC 4 Project

clock October 24, 2012 11:02 by author Scott

ASP.NET MVC 4 can be installed side by side with ASP.NET MVC 3 on the same computer, We can run both version of ASP.NET MVC projects on same machine.

If we would like upgrade an ASP.NET MVC 3 Project to ASP.NET MVC 4 Project, they are multiple ways. The simplest way to upgrade is to create a new ASP.NET MVC 4 project and copy all the views, controllers, code, and content files from the existing MVC 3 project to the new project and then to update the assembly references in the new project to match the old project. If you have made changes to the Web.config file in the MVC 3 project, you must also merge those changes into the Web.config file in the MVC 4 project.


To manually upgrade an existing ASP.NET MVC 3 application to version 4, do the following:


1. In all Web.config files in the project (there is one in the root of the project, one in the Views folder, and one in the Views folder for each area in your project), replace every instance of the following text (note: System.Web.WebPages, Version=1.0.0.0 is not found in projects created with Visual Studio 2012):


System.Web.Mvc, Version=3.0.0.0

System.Web.WebPages, Version=1.0.0.0
System.Web.Helpers, Version=1.0.0.0
System.Web.WebPages.Razor, Version=1.0.0.0

with the following corresponding text:


System.Web.Mvc, Version=4.0.0.0

System.Web.WebPages, Version=2.0.0.0
System.Web.Helpers, Version=2.0.0.0
System.Web.WebPages.Razor, Version=2.0.0.0

2. In the root Web.config file, update the webPages:Version element to "2.0.0.0" and add a new PreserveLoginUrl key that has the value "
true":



3. In Solution Explorer, right-click on the References and select Manage NuGet Packages. Search for Microsoft.AspNet.Mvc and install the Microsoft ASP.NET MVC 4 (RC) package, Click OK.


4. In Solution Explorer, right-click the project name and then select Unload Project. Then right-click the name again and select Edit ProjectName.csproj.


5. Locate the ProjectTypeGuids element and replace
{E53F8FEA-EAE0-44A6-8774-FFD645390401} with {E3E379DF-F4C6-4180-9B81-6769533ABE47}. Save the changes, close the project (.csproj) file you were editing, right-click the project, and then select Reload Project.

6. If the project references any third-party libraries that are compiled using previous versions of ASP.NET MVC, open the root Web.config file and add the following three bindingRedirect elements under the configuration section:




Looking for ASP.NET MVC 4 Hosting? Find an affordable ASP.NET MVC 4 Hosting with HostForLIFE.eu

 



European ASP.NET MVC 4 Hosting - Amsterdam :: ASP.NET Single Page Application

clock October 22, 2012 09:23 by author Scott

What is Single Page Application?

Single Page Application is an architecture for web applications. It combines the best of web and desktop, built with HTML5 and JavaScript.Single Page Applications are rich and responsive. You do not need any browser plug-ins needs to install for this architecture, it is a standard web technology that is going to work on any device, operating system and browser.

The reference for this post is http://channel9.msdn.com/Events/TechDays/Techdays-2012-the-Netherlands/2159 from Steve Sanderson’s Techdays talk,

You can develop Single Page Applications using ASP.NET MVC\Web Forms technologies.

Benefits

1. Great user experience
– It means speed, when it comes to changing of display of user interface and navigate around, we want an instance response from the application which you can get from this architecture.

2. Run on any device

3. Working off-line
– It is an interesting benefit which is just becoming possible now.

4. App-store deployable
- It is bit advanced programming but you can deploy your applications to windows market place or Apple app-store etc. This is now possible with Phone-gap third party tool for developing apps for mobiles.

The Architecture diagram looks as below



Typical Web architecture contains a server and client, where server contains an endpoint to server HTML/CSS and JS. The client side this being rendered as Visible UI and contains some javascript as well that is web technology.


What is different in Single Page Applications?

With single page web applications, you also tend to have an data end points on server and it is going to return JSON\XML to your application, You can use this data on client data access layer and render that data to UI.


We also want to have fast UI navigation, to done that we have Navigation API which allows you to book marking, navigate forth and back without talking to the server.

We can also make available all right hand side in the diagram offline. You can use local storage apis in HTML5 to work with the data offline.

Using the new Single Page Application project template and scaffolder

Create a new ASP.NET MVC application in Visual Studio, You can install MVC4 beta from here.



It will prompt you to select the project template there you can select Single Page Application project template as shown below



It creates a MVC application but the difference is it creates additional javascript libraries to make it easier for you build single page applications. If you want to use scaffolding then you can use a model class named TodoItem which will be created for you in model folder

To build a sample Single Page application using scaffolding, Add a controller to your solution



Choose the Single Page application template in controller dialogue box



Now run the application then you should be able to see the below output



What is different from other scaffolding applications is it follows single page application architecture and when you hit the browser back and forward it would not talk to the server. It also follows the all principles that we discussed on top.

 



European ASP.NET MVC Hosting - Amsterdam :: Use ASP.NET MVC Validation Attributes outside of ASP.Net

clock October 15, 2012 06:34 by author Scott

Some people love them, others absolutely hate them, but if you ask me one of the coolest features in ASP.Net MVC is the Data Annotations that you use to decorate your ASP.Net MVC classes for validation. But one of the coolest things that came along in .Net 4.0 was support for this across the whole framework – even outside of ASP.Net MVC!

When working on projects outside of ASP.Net MVC its still just as relevant to write validation for your classes and their respective properties before you fire actions, communicate them to another class or simply add something to a database (among the 4 million other times validation can come in handy).


Taking what we know from ASP.Net MVC, we can easily add this functionality to the public properties of any class in any project in .Net 4, be it a Console App, Web Service, SilverLight, Windows Phone 7 – you name it.


This also means that any common libraries you use between multiple projects can have simple Data Annotations added in one place and validated everywhere – keeping your validation logic all in one place.


Getting down to business

In the project that holds the data model classes you want to add validation to, add a reference to the framework namespace
System.ComponentModel.DataAnnotations



Now open the class you want to add validation to.


We are going to add the following to it:


- Add a class level meta data attribute telling our validator what type of class it is

- Add your validation decorations to any properties exactly as you would in ASP.Net MVC

In my example below, I demonstrate how to do this with a class named Person. You can see I've added a MetadataTypeAttribute of type Person above the class declaration. I’ve also added a required field decoration to the public Name property of this class.


[
MetadataTypeAttribute(typeof(Person))]
class
Person
{

    [Required(ErrorMessage = "You must enter a name")]
    public string Name { get; set; }
}


Now I've got to create a new class that we will use to validate our decorated attributes against objects – in this instance our Person class above, but the same code will work for any class with the correct decorations.


Create a new class in your project and call is
ClassValidator.

Paste the following code into that file:


public class
ClassValidator
{

    public ClassValidator(object objectToValidate)
    {
        objectBeingValidated = objectToValidate;
    }

    private static object objectBeingValidated { get; set; }

    public List<ValidationResult> ValidationErrors { get; private set; }

    public bool IsValid()
    {
        if (objectBeingValidated != null)
        {
            ValidationErrors = new List<ValidationResult>();
            var context = new ValidationContext(objectBeingValidated,
                null,
                null);

            bool isValid = Validator.TryValidateObject(objectBeingValidated,
                context,
                ValidationErrors);

            if (!isValid)
            {
                return false;
            }
            return true;
        }
        return false;
    }
}


And we are done - That is all we need!


Using the Code

To use the above example, all you need to do, is create an instance of our ClassValidator and pass in the object we want to validate at initialisation.


We can then call the IsValid() method against it to find out if our class validates and a list of any validation errors will then be available in the public ValidationErrors property of our ClassValidator.

My example below demonstrates this usage in a console application that does the following:

-
Creates an instance of the example Person object
- Doesn’t set any properties of this Person object (so our Name property will be Null - and therefore invalid)
-
Creates a ClassValidator and passes in my newly created Person, and then calls IsValid against it.
-
Prints all the errors found to the console.

Person p = new Person();


Console.WriteLine("Attempting to validate the person object");


ClassValidator validator = new ClassValidator(p);


Console.WriteLine("Is object valid of not?: {0}",validator.IsValid());


foreach
(var error in validator.ValidationErrors)
{

    Console.WriteLine("Error in Person object: {0}", error.ErrorMessage);
}

 



HostForLIFE.eu now supports Windows Server 2012 Hosting Platform in European Data Center

clock October 1, 2012 08:05 by author Scott

Microsoft has just officially released the highly anticipated Windows Server 2012. The newly released server operating system offers a number of features that can be utilized to benefit developers, resellers and businesses. As a premier European Windows and ASP.NET hosting provider that follow the developments of Microsoft products, HostForLIFE.eu proudly announces the support of Windows Server 2012 Hosting Platform in the world-class Amsterdam (The Netherlands) data center.

“We know that our customers are always looking for new technologies and the latest Microsoft product. With the launch of Windows Server 2012, we believe that anyone can take advantage of all the improvements available in this platform”, said Manager of HostForLIFE.eu, Kevin Joseph. “The focus on high availability, scalability, and virtualization has made this one of the most important releases of Windows Server to date. We have been working closely with Microsoft throughout the pre-release development cycle of the platform to both drive the direction of the product and ensure our team is ready to support Server 2012 solutions. We couldn’t be more excited and confident in the solutions now available to our clients with Windows Server 2012.”


With our Windows Server 2012 Hosting Platform, customers have an access directly to all the newest technologies and frameworks, such as ASP.NET 4.5 Hosting, ASP.NET MVC 4 Hosting, Silverlight 5 Hosting, WebMatrix Hosting, Visual Studio Lightswitch Hosting and SQL 2012 Hosting. All these technologies/frameworks are integrated properly on our world-class Control Panel. The package is offered from just €2.45/month and we believe that this is the most affordable, features-rich Windows and ASP.NET Hosting package in European market.


HostForLIFE.eu is awarded Top No#1 SPOTLIGHT Recommended Hosting Partner by Microsoft (see
http://www.microsoft.com/web/hosting/HostingProvider/Details/953). Our service is ranked the highest top #1 spot in several European countries, such as: Germany, Italy, Netherlands, France, Belgium, United Kingdom, Sweden, Finland, Switzerland and other European countries. Besides this award, we have also won several awards from reputable organizations in the hosting industry and the detail can be found on our official website.

For more information about our service, please visit
http://www.hostforlife.eu.

About HostForLIFE.eu:


HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.


Our number one goal is constant uptime. Our data center uses cutting edge technology, processes, and equipment. We have one of the best up time reputations in the industry.


Our second goal is providing excellent customer service. Our technical management structure is headed by professionals who have been in the industry since its inception. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.



About HostForLIFE.eu

HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.

We have offered the latest Windows 2016 Hosting, ASP.NET Core 2.2.1 Hosting, ASP.NET MVC 6 Hosting and SQL 2017 Hosting.


Tag cloud

Sign in