ASP.NET 4.5 Hosting BLOG

Tutorial and Articles about ASP.NET 4.0 and the latest ASP.NET 4.5 Hosting

Cheap and Best BugNET Hosting :: How to Install BugNET with SQL Server 2008

clock July 23, 2014 09:29 by author Ben

BugNET is an open source bug tracking tool based on SQL written in ASP.NET language. It is a cross-platform application used to keep the codebase simple. BugNET supports many features such as email notifications, multiple databases and projects supports, easy navigation, excellent security etc. The main goals are to keep the codebase simple, well documented, easy to deploy and scalable.

Installing BugNET
There are three ways you can install BugNET. You can:

  • Install it using the Web Deployment Package.
  • Download the BugNET .zip file and install it as described in Manually Installing BugNET Using a zip file.
  • Download the BugNET source code and build BugNET from the command line or in Visual Studio.


  • ASP.NET 4
  • A web server such as IIS Express 8, 7.5 or IIS 7.x.
  • Microsoft SQL Server 2008 Express or greater.

ASPHostPortal windows hosting is compatible with the BugNET. We offer BugNET based hosting plan from just $5/month (see our BugNET Hosting Plan).

And now we'll tell you about How to Install BugNET Using SQL Server 2008:

  1. Extract the contents of the install package to a folder on your computer.
  2. Create a directory in the c:\inetpub\wwwroot\ folder called bugnet (c:\inetpub\wwwroot\bugnet)
  3. Copy the contents of the BugNET folder in the install package to the c:\inetpub\wwwroot\bugnet\ folder
  4. Go to the properties of the c:\inetpub\wwwroot\bugnet\ folder, click on the Security tab, be sure to add the permissions for the appropriate user (WinXp/2000 uses the local ASPNET account, Win2003/Vista/2008/7 use the local Network Service account). Give this account modify permissions on (if necessary):
  5. Uploads - if using file system based uploads
  6. Create a virtual directory in IIS for the bugnet folder.
  7. Open up the the web server IIS Console, start-> run-> INETMGR
  8. Expand the websites node
  9. Expand the default websites node
  10. Right click on the BugNET folder under the default website, click on Convert to Application, if you don't have that option, choose properties and then add the application.
  11. Configure the database server.
  12. Load the SQL Server Management tool
  13. Expand the Server/Security node
  14. Create a blank SQL Database (e.g db name 'BugNet') on your sql server using a case insensitive collation.
  15. Configure the SQL User Security/Account to allow IIS and ASP.NET access to the database in SQL.

When the installation is complete, you may log in with the admin user account.
Username: admin
Password: password

Cheap and Best BugNET Hosting with BugNET optimised hosting infrastructure features independent email, web, database, DNS and control panel servers and a lightning fast servers ensuring your site loads super quick! Reason why you should choose us to host your BugNET site:

Easy to Use Tools - use World Class Plesk Control Panel that help you with single-click BugNET installation.
Best Programming Support - hosting servers come ready with the latest PHP version. You can get access directly to your MySQL from our world class Plesk Control Panel.
Best Server Technology - The minimal specs of our servers includes Intel Xeon Dual Core Processor, RAID-10 protected hard disk space with minimum 8 GB RAM. You dont need to worry about the speed of your site.
Best and Friendly Support - Our customer support will help you 24 hours a day, 7 days a week and 365 days a year to assist you.
Uptime & Support Guarantees - We are so confident in our hosting services we will not only provide you with a 30 days money back guarantee, but also we give you a 99.9% uptime guarantee.

Cheap ASP.NET Web Pages 3.2 Hosting :: New Features on ASP.NET Web Pages 3.2

clock July 22, 2014 13:01 by author Ben

Windows and ASP.NET hosting specialist,, has announced the availability of new hosting plans that are optimized for the latest update of the Microsoft Web Pages technology. The Web Pages 3.2,  introduces many new features including several that focus on premium media experiences and business application development.

ASP.NET Web Pages is a framework that you can use to create dynamic web pages. A simple HTML web page is static; its content is determined by the fixed HTML markup that's in the page. Dynamic pages like those you create with ASP.NET Web Pages let you create the page content on the fly, by using code.

The latest ASP.NET Web Pages 3.2  package has the following version: “3.2.0”. You can install or update these packages through NuGet. The release also includes corresponding localized packages on NuGet.

You can install or update to the released NuGet packages by using the NuGet Package Manager Console:

Install-Package Microsoft.AspNet.WebPages -Version 3.2.0

Nuget has many packages for ASP.NET Web Pages, such as:

ASP.NET Web Helpers Library
This package contains web helpers to easily add functionality to your site such as Captcha validation, Twitter profile and search boxes, Gravatars, Video, Bing search, site analytics or themes. This package is not compatible with ASP.NET MVC.

Microsoft WebPages OAuth library
This package contains the runtime assemblies for ASP.NET Web Pages. ASP.NET Web Pages and the new Razor syntax provide a fast, terse, clean and lightweight way to combine server code with HTML to create dynamic web content.

Microsoft ASP.NET Razor

This package contains the runtime assemblies for ASP.NET Web Pages. ASP.NET Web Pages and the new Razor syntax provide a fast, terse, clean and lightweight way to combine server code with HTML to create dynamic web content.

The  Advantages of ASP.NET WebPages 3.2 are :

- Framework to build dynamic web pages, typically suited for small-scale applications.
- Web pages can be developed using WebMatrix, a free tool from Microsoft which integrates web page editor, database utilities, integration with different browsers, local
- Uses Razor view engine, which is intelligent enough to understand the difference between server-side code and HTML code.

About is a hosting company that best support in Windows and ASP.NET-based hosting. Services include shared hosting, reseller hosting, and sharepoint hosting, with specialty in ASP.NET, SQL Server, and architecting highly scalable solutions. As a leading small to mid-sized business web hosting provider, strive to offer the most technologically advanced hosting solutions available to all customers across the world. Security, reliability, and performance are at the core of hosting operations to ensure each site and/or application hosted is highly secured and performs at optimum level.

ASP.NET 4.5.2 Hosting with :: Token Based Authentication using ASP.NET Web API 2, Owin, and Identity.

clock July 22, 2014 09:26 by author Kenny

In this article, we are going to explain about Token Based Authentication using ASP.NET Web API 2, Owin, and Identity. As you know that a token is a piece of data created by server, and contains information to identify a particular user and token validity. The token will contain the user's information, as well as a special token code that user can pass to the server with every method that supports authentication, instead of passing a username and password directly.

What is Token Based Authentication?

Token-based authentication is a security technique that authenticates the users who attempt to log in to a server, a network, or some other secure system, using a security token provided by the server. An authentication is successful if a user can prove to a server that he or she is a valid user by passing a security token. The service validates the security token and processes the user request. After the token is validated by the service, it is used to establish security context for the client, so the service can make authorization decisions or audit activity for successive user requests.

The general concept behind a token-based authentication system is simple. Allow users to enter their username and password in order to obtain a token which allows them to fetch a specific resource - without using their username and password. Once their token has been obtained, the user can offer the token - which offers access to a specific resource for a time period - to the remote site.

What is ASP.NET Web API 2, Owin, and Identity?

This article is about Token Based Authentication using ASP.NET Web API 2, Owin, and Identity. ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. ASP.NET Web API is an ideal platform for building RESTful applications on the .NET Framework. ASP.NET Identity is the reworked, flexible replacement for the old membership system that has been around since ASP.NET 2.0. ASP.NET Identity is more well designed and flexible than the old membership system and uses Owin middleware components for external logins such as Facebook, Google and Twitter.

Building the Back-End API

Step 1: Creating the Web API Project

Now create an empty solution and name it “AngularJSAuthentication” then add new ASP.NET Web application named “AngularJSAuthentication.API”, the selected template for project will be as the image below. Notice that the authentication is set to “No Authentication” taking into consideration that we’ll add this manually.

Step 2: Installing the needed NuGet Packages:

Now we need to install the NuGet packages which are needed to setup our Owin server and configure ASP.NET Web API to be hosted within an Owin server, so open NuGet Package Manger Console and type the below:

Install-Package Microsoft.AspNet.WebApi.Owin -Version 5.1.2

Install-Package Microsoft.Owin.Host.SystemWeb -Version 2.1.0

The  package “Microsoft.Owin.Host.SystemWeb” is used to enable our Owin server to run our API on IIS using ASP.NET request pipeline as eventually we’ll host this API on Microsoft Azure Websites which uses IIS.

Step 3: Add Owin “Startup” Class

Right click on your project then add new class named “Startup”. We’ll visit this class many times and modify it, for now it will contain the code below:
using Microsoft.Owin;
using Owin;
using System;
using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.Http;

[assembly: OwinStartup(typeof(AngularJSAuthentication.API.Startup))]

namespace AngularJSAuthentication.API


    public class Startup


        public void Configuration(IAppBuilder app)


            HttpConfiguration config = new HttpConfiguration();






What we’ve implemented above is simple, this class will be fired once our server starts, notice the “assembly” attribute which states which class to fire on start-up. The “Configuration” method accepts parameter of type “IAppBuilder” this parameter will be supplied by the host at run-time. This “app” parameter is an interface which will be used to compose the application for our Owin server.

The “HttpConfiguration” object is used to configure API routes, so we’ll pass this object to method “Register” in “WebApiConfig” class.

Lastly, we’ll pass the “config” object to the extension method “UseWebApi” which will be responsible to wire up ASP.NET Web API to our Owin server pipeline.

Usually the class “WebApiConfig” exists with the templates we’ve selected, if it doesn’t exist then add it under the folder “App_Start”. Below is the code inside it:

    public static class WebApiConfig
       public static void Register(HttpConfiguration config)
            // Web API routes

                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }

           var jsonFormatter = config.Formatters.OfType<JsonMediaTypeFormatter>().First();

            jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();

Step 4: Delete Global.asax Class

No need to use this class and fire up the Application_Start event after we’ve configured our “Startup” class so feel free to delete it.

Step 5: Add the ASP.NET Identity System

After we’ve configured the Web API, it is time to add the needed NuGet packages to add support for registering and validating user credentials, so open package manager console and add the below NuGet packages:

Install-Package Microsoft.AspNet.Identity.Owin -Version 2.0.1

Install-Package Microsoft.AspNet.Identity.EntityFramework -Version 2.0.1

The first package will add support for ASP.NET Identity Owin, and the second package will add support for using ASP.NET Identity with Entity Framework so we can save users to SQL Server database.

Now we need to add Database context class which will be responsible to communicate with our database, so add new class and name it “AuthContext” then paste the code snippet below:

public class AuthContext : IdentityDbContext<IdentityUser>
        public AuthContext()
            : base("AuthContext")

As you can see this class inherits from “IdentityDbContext” class, you can think about this class as special version of the traditional “DbContext” Class, it will provide all of the Entity Framework code-first mapping and DbSet properties needed to manage the identity tables in SQL Server.

Step 6: Add Repository class to support ASP.NET Identity System

Now we want to implement two methods needed in our application which they are: “RegisterUser” and “FindUser”, so add new class named “AuthRepository” and paste the code snippet below:

    public class AuthRepository : IDisposable
        private AuthContext _ctx;

        private UserManager<IdentityUser> _userManager;
        public AuthRepository()
            _ctx = new AuthContext();
            _userManager = new UserManager<IdentityUser>(new UserStore<IdentityUser>(_ctx));

        public async Task<IdentityResult> RegisterUser(UserModel userModel)
          IdentityUser user = new IdentityUser
            {            UserName = userModel.UserName
            var result = await _userManager.CreateAsync(user, userModel.Password);
            return result;
        public async Task<IdentityUser> FindUser(string userName, string password)
        IdentityUser user = await _userManager.FindAsync(userName, password);
            return user;
        public void Dispose()

Step 7: Add our “Account” Controller

Now it is the time to add our first Web API controller which will be used to register new users, so under file “Controllers” add Empty Web API 2 Controller named “AccountController” and paste the code below:

    public class AccountController : ApiController
          private AuthRepository _repo = null;
          public AccountController()
           _repo = new AuthRepository();
        // POST api/Account/Register
        public async Task<IHttpActionResult> Register(UserModel userModel)
         if (!ModelState.IsValid)
              return BadRequest(ModelState);
            IdentityResult result = await _repo.RegisterUser(userModel);
            IHttpActionResult errorResult = GetErrorResult(result);
            if (errorResult != null)
              return errorResult;
              return Ok();
        protected override void Dispose(bool disposing)
           if (disposing)
        private IHttpActionResult GetErrorResult(IdentityResult result)
          if (result == null)
             return InternalServerError();
            if (!result.Succeeded)
              if (result.Errors != null)
                  foreach (string error in result.Errors)
                     ModelState.AddModelError("", error);
                if (ModelState.IsValid)
                // No ModelState errors are available to send, so just return an empty BadRequest.
                    return BadRequest();
                return BadRequest(ModelState);
            return null;

Step 8: Add Secured Orders Controller

Now we want to add another controller to serve our Orders, we’ll assume that this controller will return orders only for Authenticated users, to keep things simple we’ll return static data. So add new controller named “OrdersController” under “Controllers” folder and paste the code below:

    public class OrdersController : ApiController
        public IHttpActionResult Get()
         return Ok(Order.CreateOrders());
    #region Helpers
    public class Order
   public int OrderID
        public string CustomerName
        public string ShipperCity
        public Boolean IsShipped
        public static List<Order> CreateOrders()
         List<Order> OrderList = new List<Order>
                new Order {OrderID = 10248, CustomerName = "Taiseer Joudeh", ShipperCity = "Amman", IsShipped = true },
                new Order {OrderID = 10249, CustomerName = "Ahmad Hasan", ShipperCity = "Dubai", IsShipped = false},
                new Order {OrderID = 10250,CustomerName = "Tamer Yaser", ShipperCity = "Jeddah", IsShipped = false },
                new Order {OrderID = 10251,CustomerName = "Lina Majed", ShipperCity = "Abu Dhabi", IsShipped = false},
                new Order {OrderID = 10252,CustomerName = "Yasmeen Rami", ShipperCity = "Kuwait", IsShipped = true}
            return OrderList;

Step 9: Add support for OAuth Bearer Tokens Generation

Till this moment we didn’t configure our API to use OAuth authentication workflow, to do so open package manager console and install the following NuGet package:

Install-Package Microsoft.Owin.Security.OAuth -Version 2.1.0

After you install this package open file “Startup” again and call the new method named “ConfigureOAuth” as the first line inside the method “Configuration”, the implemntation for this method as below:

public class Startup
    public void Configuration(IAppBuilder app)
                    //Rest of code is here;
        public void ConfigureOAuth(IAppBuilder app)
          OAuthAuthorizationServerOptions OAuthServerOptions = new OAuthAuthorizationServerOptions()
                AllowInsecureHttp = true,
                TokenEndpointPath = new PathString("/token"),
                AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),
                Provider = new SimpleAuthorizationServerProvider()
            // Token Generation
            app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());

Step 10: Implement the “SimpleAuthorizationServerProvider” class

Add new folder named “Providers” then add new class named “SimpleAuthorizationServerProvider”, paste the code snippet below:

public class SimpleAuthorizationServerProvider : OAuthAuthorizationServerProvider
      public override async Task ValidateClientAuthentication(OAuthValidateClientAuthenticationContext context)
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
   context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });
            using (AuthRepository _repo = new AuthRepository())
   IdentityUser user = await _repo.FindUser(context.UserName, context.Password);
                if (user == null)
                {context.SetError("invalid_grant", "The user name or password is incorrect.");
            var identity = new ClaimsIdentity(context.Options.AuthenticationType);
            identity.AddClaim(new Claim("sub", context.UserName));
            identity.AddClaim(new Claim("role", "user"));

Step 11: Allow CORS for ASP.NET Web API

First of all we need to install the following NuGet package manger, so open package manager console and type:

Install-Package Microsoft.Owin.Cors -Version 2.1.0

Now open class “Startup” again and add the highlighted line of code (line 8) to the method “Configuration” as the below:

public void Configuration(IAppBuilder app)
            HttpConfiguration config = new HttpConfiguration();
            app.UseWebApi(config);        }

Step 12: Testing the Back-end API

Assuming that you registered the username “Taiseer” with password “SuperPass” in the step below, we’ll use the same username to generate token, so to test this out open your favorite REST client application in order to issue HTTP requests to generate token for user “Taiseer”. For me I’ll be using PostMan.

Cheap and Best DotNetOpenAuth Hosting :: Integrating OpenAuth/OpenID With Your ASP.NET MVC Application

clock July 22, 2014 08:47 by author Ben

DotnetOpenAuth is a open source library that allows the developers to add the OpenId and OAuth capabilities to their ASP.NET Web Application. It allows the developers to include the OpenId support by just dragging and dropping a ASP.NET control to the Web Page.

What is OpenId?

OpenId is a single sign-on scheme – the idea is that you keep your login and profile information in one place so that you don’t have to login at every Web location and create new user credentials on each site. The  idea of a single sign on isn’t new of course – lots of these things have been around over the years with the most remembered probably being Microsoft’s Passport/Windows Live ID (not that anybody likes Windows Live Id).

What is OAuth?

OAuth is the main protocol. It is stable and ready to be implemented. Libraries are already available for many popular platforms such as PHP, Rails, Python, .NET, C, and Perl. We expect most upcoming work to focus on implementations and the development of extensions to the protocol.

And now, we'll tell you about Integrating OpenAuth/OpenID with your ASP.NET MVC application, for this tutorial I use ASP.NET MVC 4.0 and Visual Studio 2012.

Step 1: Create a new project

  • Go to File 
  • New Project  Web
  • Empty Asp.Net MVC 4 Application

Step 2: Add the following libraries

  • Use Nuget to get the following packages
  • DotNetOpenAuth.AspNet
  • Microsoft.AspNet.Providers.Core
  • Microsoft.AspNet.Providers.LocalDb
  • Microsoft.AspNet.Membership.OpenAuth

Step 3: Change web.config to use formsauthentication

<authentication mode="Forms">

   <forms loginUrl="~/Auth/Logon" timeout="2880" />


Step 4: Adding AuthConfig

Add a new class called AuthConfig.cs to folder App_Start that class will contains the register functions for all services that we will integrate

Add the following code to AuthConfig.cs and don’t forget to get services Api keys from each service website

public static void RegisterAuth()

clientId: "",
clientSecret: "");
consumerKey: "",
consumerSecret: "");
appId: "",
appSecret: "");
consumerKey: "",
consumerSecret: "");

Register AuthConfig to application start Go to Global.asax and add the following line to Application_Start function

Step 5: Adding Login functionality

Add a new controller for Authentication functionality called it AuthController.cs
add Logon Action for login page

public ActionResult Logon()
return View(OAuthWebSecurity.RegisteredClientData);

as you can notice that we user OAuthWebSecurity.RegisteredClientData as a model that object will contain all registered services that we put at AuthConfig class. Add a markup for login page

@using Microsoft.Web.WebPages.OAuth;
@model ICollection<AuthenticationClientData>
//Add this inside body
        @using (Html.BeginForm("ExternalLogin", "Auth", new { ReturnUrl = ViewBag.ReturnUrl }))
                @foreach (AuthenticationClientData p in Model)
                    <button type="submit" name="provider" value="@p.AuthenticationClient.ProviderName" title="Log in using your @p.DisplayName account">@p.DisplayName</button>

as you can notice that we are looping against the services that we already registered in a previous step each AuthenticationClientData represent a service so we create a button to call that service we are adding all the buttons inside single form that calling ExternalLogin action method. Add ActionMethod ExternalLogin

public void ExternalLogin(string provider, string returnUrl)
  OAuthWebSecurity.RequestAuthentication(provider, Url.Action("ExternalLoginCallback", new { ReturnUrl = returnUrl }));

We are using OAuthWebSecurity.RequestAuthentication this function is requesting the authentication from the requested provider service “Facebook – Twitter – etc.”

        public ActionResult ExternalLoginCallback(string returnUrl = "")
            AuthenticationResult result = OAuthWebSecurity.VerifyAuthentication(Url.Action("ExternalLoginCallback", new { ReturnUrl = returnUrl }));
            if (!result.IsSuccessful)
                return RedirectToAction("ExternalLoginFailure");
            //if (OAuthWebSecurity.Login(result.Provider, result.ProviderUserId, createPersistentCookie: false))
            //    return RedirectToLocal(returnUrl);
            if (User.Identity.IsAuthenticated)
                // If the current user is logged in add the new account
                OAuthWebSecurity.CreateOrUpdateAccount(result.Provider, result.ProviderUserId, User.Identity.Name);
                return RedirectToLocal(returnUrl);
                // User is new, ask for their desired membership name
                string loginData = OAuthWebSecurity.SerializeProviderUserId(result.Provider, result.ProviderUserId);
                ViewBag.ProviderDisplayName = OAuthWebSecurity.GetOAuthClientData(result.Provider).DisplayName;
                ViewBag.ReturnUrl = returnUrl;
                OAuthAccount oAuthAccount = new OAuthAccount(result.Provider, result.ProviderUserId);
                return View("ExternalLoginConfirmation", new RegisterExternalLoginModel { UserName = result.UserName, ExternalLoginData = loginData });
 private ActionResult RedirectToLocal(string returnUrl)
            if (Url.IsLocalUrl(returnUrl))
                return Redirect(returnUrl);
                return RedirectToAction("Index", "Home");

We have to verify authentication to ensure that the account is successfully authenticated if not redirect users to ExternalLoginFailure action if user is authenticated then we are going to login user to the system using simple membership we are going to talk about that in later posts then check if the current user is logged in add the new account else user is new, ask for their desired membership name then redirect to ExternalLoginConfirmation action with user information at RegisterExternalLoginModel class

public ActionResult ExternalLoginConfirmation(RegisterExternalLoginModel model)
           return View(model);
public class RegisterExternalLoginModel
        [Display(Name = "User name")]
        public string UserName { get; set; }
        public string ExternalLoginData { get; set; }

and now run your program.

DotNetOpenAuth Hosting with is Microsoft No #1 Recommended Windows and ASP.NET Spotlight Hosting Partner in United States. Microsoft presents this award to for ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2012, ASP.NET 4.5, ASP.NET MVC 4.0, Silverlight 5 and Visual Studio Lightswitch. will now DotNetOpenAuth Hosting (extensions for ASP.NET (WebPages)) service on all of our hosting plans, starting at just $5.00/mo! We offer completely Windows ASP.NET  website hosting that is fast, reliable and packed with fantastic features to publish your websites online.

Cheap Node.JS Hosting :: How to Solve Error Handling Callback in Node.JS

clock July 17, 2014 12:09 by author Ben

Error handling can be a drag, but it’s essential for the stability of your app. Naturally, I’m interested in ways to streamline the error handling process to make it as stable as it can be for the app whilst also being convenient for me to write. The async callback standard in Node.js suggests that the first parameter of the callback is an error object. If that's null, you can move along. If it's not, or you have an error thrown elsewhere, you have to figure out what to do. Let's take a look at our options!

Callback can carry on assuming the operation succeeded. Otherwise, it can deal with the error in an appropriate way, such as logging it along with any contextual information. It can then decide whether or not to carry on depending on the severity of the error or whether or not the resultant data is required to continue operation.

Let’s implement some error handling for our query error:

var log = console.log;
// We misspell 'SELECT' in this query so it fails
var query = 'SLECT 1 + 1';
con.query(query, function(err){
  if (err) return log("Query failed. Error: %s. Query: %s", err, query);

Our favourite library for asynchronous flow control is async. Both async.parallel and async.series accept a collection of operations, and if any of them pass an error to its callback, async will immediately invoke your completion callback with the error:

var async = require('async');
var log = console.log;
var op1 = function(cb) {
  // We misspell 'SELECT' in this query so it fails
  var query = 'SLECT 1 + 1';
  con.query(query, cb);

var op2 = function(cb) {
  // This query is fine
  con.query('SELECT 1 + 1', cb);

var ops = [op1, op2];

async.parallel(ops, function(err, results) {
  if (err) return log("Something went wrong in one of our ops. Err: %s", err);

  // Otherwise, process results

async.parallel will execute both op1 and op2 in parallel but if either or both fail it will invoke our completion callback with the error that occurred first.

Standard callbacks are all well and good when we’re following Node’s convention, but it’s a little bit laborious to check the result of every operation, and this can quickly get messy when there are many nested callbacks each with their own error handling code.

Best, Fast, and Reliable Node.js Web Hosting with

Business Ready Technology Solutions
We understand that IT isn’t a one-size-fits-all scenario. That’s why all of our enterprise hardware, software and cloud-based technology solutions can be customized to fit the needs of your business, while being flexible enough to grow as you grow.

Reliability - 99.9% uptime
That is the promise we make to you. Our proprietary software and expert system administrators monitor our servers 24 hours a day, 7 days a week.

Highly Secured
We are independent, and have our own infrastructure. Every application runs on HTTPS protocol by default.

ASP.NET MVC 5 Hosting - ASPHostPortal :: How to Perform Code First Migration in MVC 5

clock July 16, 2014 08:39 by author Jervis

In today post, I will explain Code Migration in MVC application. This migration helps you to update and change the data model that you’ve created for application and you don't need to re-create or drop your database.


How to Apply Code First Migration

The data model in the database usually changes after developing the new application. When the data model changes, it becomes out of sync with the database. We've configured our Entity Framework in the app to drop and recreate the data model automatically. When any type of change is done in the entity classes or in the DbContext class, the existing database is deleted and the new database is created that matches the model and sees it with test data.

When the application runs in production, we do not want to lose everything each time we make changes like adding a column. The Code First Migration solved this problem by enabling the code first to update the database instead of dropping or recreating.

The procedure is following:

1. Disable the Database Initializer in the Web.Config file.

The following is the example:


      <context type="Vag_Infotech.DAL.CollegeDbContext, Vag_Infotech">
        <databaseInitializer type="Vag_Infotech.DAL.CollegeDatabaseInitializer, Vag_Infotech"></databaseInitializer>

And also you need to change your Global.asax file:

// Database.SetInitializer(new CollegeDatabaseInitializer()); 

2. Change your database name in your web.config file:

  <add name="CollegeDbContext" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=VInfotechNew;Integrated Security=SSPI" providerName="System.Data.SqlClient" />

3. Open the Package Manager Console and enter this command:


add-migration InitialCreate 

Then, you will see the solution explorer below:

How to Edit Seed Method

Now, we add new code for updating our data model in this method. When we do not use the migration, the data model is dropped or re-created during the execution of the application each time, but now the data is retained after database changes.

Here are the steps to edit seed method:

1. Modify your configuration.cs file with this code:

namespace Vag_Infotech.Migrations
    using System;
    using System.Collections.Generic;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Linq;
    using Vag_Infotech.Models;
    internal sealed class Configuration : DbMigrationsConfiguration<Vag_Infotech.DAL.CollegeDbContext>
        public Configuration()
            AutomaticMigrationsEnabled = false;
        protected override void Seed(Vag_Infotech.DAL.CollegeDbContext context)
            var New_Students = new List<Student>
                new Student{FirstName="Louis",LastName="Fordsen",
                new Student{FirstName="David ",LastName="Roger",
                new Student{FirstName="Mike",LastName="Upson",
            New_Students.ForEach(ns => context.Students.AddOrUpdate(p => p.LastName, ns));
            var New_Courses = new List<Course>
                new Course{CourseID=201,Name="MCA",Credit=3,},
                new Course{CourseID=202,Name="M.Sc.IT",Credit=2,},
                new Course{CourseID=203,Name="M.Tech.CS",Credit=2,},
                new Course{CourseID=204,Name="M.Tech.IT",Credit=4,}
            New_Courses.ForEach(ns => context.Courses.AddOrUpdate(p => p.Name, ns));
            var New_Enrollments = new List<Enrollment>
                new Enrollment{
                    StudentID= New_Students.Single(ns=>ns.FirstName=="Louis").ID,
                new Enrollment{
                    StudentID= New_Students.Single(ns=>ns.FirstName=="David").ID,
                new Enrollment{
                    StudentID= New_Students.Single(ns=>ns.FirstName=="Mike").ID,
            foreach (Enrollment et in New_Enrollments)
                var NewEnrollDb = context.Enrollments.Where(
                    ns => ns.Student.ID == et.StudentID &&
                        ns.Course.CourseID == et.CourseID).SingleOrDefault();
                if (NewEnrollDb == null)

In the code above the Seed() takes the context object as an input argument and in the code the object is used to add the entities to the database. We can see how the code creates the collection for the database for each entity type and then saves it by SaveChanges() and adds it through the DbSet property. It is not necessary to call the SaveChanges() after each group of entities.

2. Build the solution

How to Execute the Migration

Here are steps:

1. Enter this command on Package Manager Console:


2. Run the application and you’ll see the change

Cheap WebSocket Hosting Tutorial :: How to Enable or Disable WebSocket Protocol on Windows Server 2012 and Windows 8

clock July 15, 2014 08:32 by author Ben

Websocket implements the server side of the WebSocket protocol. The WebSocket protocol is a protocol introduced in HTML5, intended to replace Comet and other long-polling solutions, to provide a rich communication mechanism over HTTP. The WebSocket protocol was standardized by IETF as RFC 6455. We could find introductions and more information on Wikipedia and W3C.

Microsoft .NET 4.5 provides several ways in using WebSocket. On the server side, we can host our WebSocket server through any one of the ways below:

  • Using HttpContext.AcceptWebSocketRequest
  • Creating a WCF service with CallbackContract and the new netHttpBinding
  • Using WebSocketHandler or WebSocketHost provided in Microsoft.WebSockets.dll

Here is the step by step how to enable WebSocket Protocol on Windows
Server 2012 and Windows 8 on server side:

NOTE: The web server must be IIS 8 and above.

Enable WebSocket Protocol in Windows Server 2012

On Windows Server 2012, you could do that through Server Manager -> Manage -> Add Roles and Features. -> Expand the Web Server (IIS) role and check Web Server -> Application Development -> WebSocket Protocol.

Enable WebSocket Protocol in Windows 8

Open "Control Panel" -> Open "Turn Windows features on or off" -> Expand Internet Information Services” -> Expand World Wide Web Services” -> ExpandApplication Development Features" -> Checklist WebSocket Protocol and clickOK

Disable WebSocket when using on node.js

If you are using the WebSocket support in on node.js in your site, you will need to disable the default IIS WebSockets module by adding the below snippet to your web.config or applicationHost.config. If this is not done, the IIS WebSockets module will attempt to handle the WebSocket communication rather than letting this task fall through to node.js (and hence your application). This will result in unexpected errors when you attempt to access your site.

    <webSocket enabled=”false”/>

Reasons to Trust Your ASP.NET 4.5 Websockets Hosting to

Uptime & Support Guarantees
We are so confident in our hosting services we will not only provide you with a 30 days money back guarantee, but also we give you a 99.9% uptime guarantee.
A Powerful User-Friendly Control Panel
Our Control Panel provides the tools and utilities, which give you true control over your account and web pages.

Setup Installation
We'll get you up and running within 30 seconds of placing your order.

Cheap ASP.NET Hosting Tips :: How to Integrate Paypal in ASP.NET Site

clock July 11, 2014 09:17 by author Ben

This article discusses integration of PayPal Payment in ASP.NET web application. Nowadays PayPal is the most popular payment gateway worldwide because it is totally free to integrate and PayPal does not charge anything for opening an account, you will pay PayPal when you get paid. And the amount is also lower than other payment gateways.

PayPal supports several types of payments:

  • Payments for goods in the PayPal cart. PayPal is responsible for all operations supporting the cart in this case. Unfortunately, this option does not provide the maximum flexibility that is required to implement some projects, so the article does not consider this option.
  • Recurring billing or subscription. PayPal provides a subscription capability; that means that a definite sum will be periodically transferred from the user's account to the seller's account. The user can unsubscribe anytime. The seller can specify the subscription's period and cost. He also can organize a trial period to let the user assess the quality of services he provides. The trial period can be either paid or free.
  • "One click" shopping. Goods are not put into the cart in this case. This method also is used to pay for goods in a cart that was filled without PayPal. That's why this option provides maximum flexibility and full control of the cart.

Let’s start step by step work to integrate PayPal payment :

1.  Create PayPal account on PayPal Sandbox: Basically, PayPal provides an environment to developer that how they can integrate PayPal payment in their website. So just open URL: and click on SignUp option.

2. Create buyer (Personal Account) and one seller account (Business Account) PayPal account.

3. Having a valid PayPal API Token Key

4. Having PayPal business account email id

5. Create New Page on ASP.NET project and copy this script :


<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"

    CodeFile="Default.aspx.cs" Inherits="_Default" %>


<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">


<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">


        <table width="700" align="center" cellpadding="0" cellspacing="0">


                <td height="60">

                    <b>Paypal Integration in ASP.NET</b>




                <td height="40" align="center">

                    <asp:GridView ID="gvPayPal" runat="server" AutoGenerateColumns="False" OnRowCommand="gvPayPal_RowCommand"

                        BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"

                        CellPadding="3" CellSpacing="2">

                        <RowStyle ForeColor="#8C4510" BackColor="#FFF7E7" />


                            <asp:TemplateField HeaderText="Product Name">


                                    <asp:Label ID="lblName" runat="server" Text='<%#Eval("prodName") %>'></asp:Label>



                            <asp:TemplateField HeaderText="Product Description">


                                    <asp:Label ID="lblDescription" runat="server" Text='<%#Eval("prodDesc") %>'></asp:Label>



                            <asp:TemplateField HeaderText="Product price">


                                    <asp:Label ID="lblProductPrice" runat="server" Text='<%#Eval("prodPrice") %>'></asp:Label>



                            <asp:TemplateField HeaderText="Buy Now">


                                    <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/images/buy.png"

                                       Width="64" Height="64" CommandName="buy" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" />




                        <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />

                        <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />

                        <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />

                        <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />

                        <SortedAscendingCellStyle BackColor="#FFF1D4" />

                        <SortedAscendingHeaderStyle BackColor="#B95C30" />

                        <SortedDescendingCellStyle BackColor="#F1E5CE" />

                        <SortedDescendingHeaderStyle BackColor="#93451F" />





        <!-- PayPal Logo -->

        <table border="0" cellpadding="10" cellspacing="0" align="center">


                <td align="center">




                <td align="center">

                    <a style="cursor:pointer;" title="Paypal payment gateway center" onclick="'','olcwhatispaypal','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=400, height=350');">

                        <img src="" border="0"

                            alt="Solution Graphics"></a>




        <!-- PayPal Logo -->




using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Configuration;

using System.Data.SqlClient;

using System.Data;


public partial class _Default : System.Web.UI.Page


    SqlConnection Con = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ToString());

    SqlCommand cmd = new SqlCommand();

    SqlDataAdapter da = new SqlDataAdapter();

    DataTable dt = new DataTable();

    DataRow dr;


    protected void Page_Load(object sender, EventArgs e)


        if (!Page.IsPostBack)


            //Add some column to datatable display some products information           





            //Add rows with datatable and bind in the grid view

            dr = dt.NewRow();

            dr["prodName"] = "MindStick Cleaner";

            dr["prodDesc"] = "Cleans all system dummy data";

            dr["prodPrice"] = "$100.00";



            dr = dt.NewRow();

            dr["prodName"] = "MindStick DataConverter";

            dr["prodDesc"] = "Helps to import export data in different format";

            dr["prodPrice"] = "$120.00";



            dr = dt.NewRow();

            dr["prodName"] = "MindStick SurveyManager";

            dr["prodDesc"] = "Helps creating survey page with specified format dll";

            dr["prodPrice"] = "$140.00";



            dr = dt.NewRow();

            dr["prodName"] = "MindStick TeraByte Importer";

            dr["prodDesc"] = "Data transfer utility";

            dr["prodPrice"] = "$30.00";



            gvPayPal.DataSource = dt;





    protected void gvPayPal_RowCommand(object sender, GridViewCommandEventArgs e)


        if (e.CommandName == "buy")


            ImageButton ib = (ImageButton)e.CommandSource;

            int index = Convert.ToInt32(ib.CommandArgument);

            GridViewRow row = gvPayPal.Rows[index];


            //Get each Column label value from grid view and store it in label

            Label pName = (Label)row.FindControl("lblName");

            Label pDescription = (Label)row.FindControl("lblDescription");

            Label pPrice = (Label)row.FindControl("lblProductPrice");


            //Here store that person name who are going to make transaction

            Session["user"] = "Arun Singh";


            // make query string to store logged in user information in sql server table         

            string query = "";

            query = "insert into purchase(pname,pdesc,price,uname) values('" + pName.Text + "','" + pDescription.Text + "','" + pPrice.Text.Replace("$", "") + "','" + Session["user"].ToString() + "')";


            cmd = new SqlCommand(query, Con);




            //Pay pal process Refer for what are the variable are need to send


            string redirectUrl = "";


            //Mention URL to redirect content to paypal site

            redirectUrl += "" + ConfigurationManager.AppSettings["paypalemail"].ToString();


            //First name I assign static based on login details assign this value

            redirectUrl += "&first_name=Arun_Seller";


            //Product Name

            redirectUrl += "&item_name=" + pName.Text;


            //Product Amount

            redirectUrl += "&amount=" + pPrice.Text;


            //Business contact paypal EmailID

            redirectUrl += "&business=[email protected]";


            //Shipping charges if any, or available or using shopping cart system

            redirectUrl += "&shipping=5";


            //Handling charges if any, or available or using shopping cart system

            redirectUrl += "&handling=5";


            //Tax charges if any, or available or using shopping cart system

            redirectUrl += "&tax=5";


            //Quantiy of product, Here statically added quantity 1

            redirectUrl += "&quantity=1";


            //If transactioin has been successfully performed, redirect SuccessURL page- this page will be designed by developer

            redirectUrl += "&return=" + ConfigurationManager.AppSettings["SuccessURL"].ToString();


            //If transactioin has been failed, redirect FailedURL page- this page will be designed by developer

            redirectUrl += "&cancel_return=" + ConfigurationManager.AppSettings["FailedURL"].ToString();








USE [MyDatabase]



/****** Object:  Table [dbo].[purchase]    Script Date: 01/27/2013 09:26:07 ******/










CREATE TABLE [dbo].[purchase](

      [Id] [int] IDENTITY(1,1) NOT NULL,

      [PName] [nvarchar](100) NULL,

      [PDesc] [nvarchar](100) NULL,

      [Price] [money] NULL,

      [Uname] [varchar](50) NULL,



      [Id] ASC








On web.config file:

<?xml version="1.0"?>


  For more information on how to configure your ASP.NET application, please visit




    <add name="ApplicationServices" connectionString="data source=Arun-PC;Integrated Security=true; Initial Catalog= MyDatabase; User Id= Arun-PC; Password= mindstick;" providerName="System.Data.SqlClient"/>



    <compilation debug="true" targetFramework="4.0"/>

    <authentication mode="Forms">

      <forms loginUrl="~/Account/Login.aspx" timeout="2880"/>





        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>






        <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>



    <roleManager enabled="false">



        <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/"/>

        <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/"/>





    <add key="token" value="(insert your paypal API Signature) "/>

    <add key="paypalemail" value="(insert with paypal login email id)"/>

    <!--Here i used sandbox site url only if you hosted in live change sandbox to live paypal URL-->

    <add key="PayPalSubmitUrl" value=""/>

    <add key="FailedURL" value="http://localhost:49666/PayPalIntegration/Failed.aspx"/> <!--Failed Page URL-->

    <add key="SuccessURL" value="http://localhost:49666/Default.aspx"/> <!--Success Page URL-->



    <modules runAllManagedModulesForAllRequests="true"/>



6. Run the project to see the result.


Look no further! You have found the answer. is your ASP.NET 4.5 hosting home! We understand that as .NET developer, you need to find good .NET hosting that provide reliable and cheap .NET hosting. supports the latest .NET framework, .NET 4.5, as well as past frameworks like .NET 4, .NET 3.5, and .NET 2.0. All of our .NET hosting comes with FREE Trial Hosting. If the service does not meet your expectations, simply cancel before the end of the free trial period. No Risk!! Why wait longer?

ASP.NET 4.5.2 Hosting with :: SEO Tips for Your ASP.NET Site

clock June 16, 2014 06:43 by author Kenny

In this article I will give you SEO tips for your ASP.NET site. Search Engine Optimization is the process of improving the visibility of a website on organic ("natural" or un-paid) search engine result pages (SERPs), by incorporating search engine friendly elements into a website. SEO helps to ensure that a site is accessible to a search engine and improves the chances that the site will be found by the search engine.

ASP.NET (originally called ASP+) is the next generation of Microsoft's Active Server Page (ASP), a feature of their Internet Information Server (IIS). The latest version of ASP.NET is ASP.NET 4.5.2. Well, here are 10 tips on SEO for your ASP.NET website.


Every page in your website should have a unique and descriptive page title that can describe what the page offers. You can set the Page Title either declaratively or in the code behind file.
This is very easy to achieve, and has a big influence on your site's ranking: don't use static titles. The <title> tag is one of the best ways to optimize a site for a special topic or keyword. Don't use a dozen keywords in the title tag, because you're "paying in" for each and every keyword - "paying in" means, that the weight of your site gets divided for all the keywords mentioned in the title tag. Choose one or two keywords, or a keyword-combination, to achieve relevance and a good ranking.


Make sure all your links in your page are hyperlinks. Search engines can crawl a page only if it is linked through a hyper link (anchor tag). JavaScript navigations are not search engine friendly since search engines will not understand it.


Add Meta keyword and Meta description tag with relevant contents. Search engines will use these tags to understand what the page offers.


Make your website URL descriptive. URL’s that has lots of query string values, numeric ids are not descriptive. It will provide enough information what the page offers. For example, is not descriptive as


Add ALT text for images and Title for hyperlinks. The ALT text will be displayed when the browser cannot display the image for some reasons. Search engines will not be able to read the image and ALT text will give some hint about the image which the search engine can use.


Try to design your page with very less media contents like images, flash objects, Silverlight objects, ActiveX objects, etc. Search engines can only read HTML contents. A page that is entirely build on flash or Silverlight are not search engine friendly since the search engine robots cannot find any textual contents in those pages.


Use Header tags (H1, H2, H3, H4, H5 and H6) wherever appropriate instead of styling the text in SPAN tags. These Header tags are search engine friendly. You can use this tag efficiently to organize your page headings and sub headings.
For example, you can put your page top most heading in H1, sub heading in H2, sub-sub heading in H3, etc that represents a proper hierarchy of your page contents.


Previously there was a limit in number of links (100 links per page) the Google search engine will index on a page. This restriction is now no more. But it is still advisable to have limited number of links in your pages to avoid any adverse effect on your site rank.  This is to prevent link spamming and to preserve the page rank.


Always have a sitemap file that can guide users and search engines to navigate your site pages easily. It is really necessary to have 2 site maps for a site, an xml sitemap file used by the search engines and an html sitemap file for the website users. You can submit your xml sitemap or RSS feed to Google Webmaster tools.


Always construct search engine friendly pager links when displaying list of items in a summary page. For example, product list, article list page, etc. A link is called search engine friendly if it is anchor tag (<A>) that has a reachable url in its href property through GET request.

ASP.NET MVC 6 Hosting with :: ASP.NET vNext in ASP.NET MVC 6

clock June 13, 2014 09:08 by author Kenny

The vNext tag has been placed on the next version of ASP.NET MVC 6. ASP.NET vNext will be optimized for the cloud, which means applications will (or should) have only the pieces that it needs. In addition, it promises more flexible componentization and better class performance and startup times. An interesting twist is ASP.NET vNext will be an open source project as part of the .NET Foundation. In addition, the .NET compiler platform "Roslyn" is open sourced as well.

.NET vNext support true side-by-side deployment. If your app is using cloud-optimized subset of .NET vNext, you can deploy all of your dependencies including the .NET vNext (cloud optimized) by uploading bin to hosting environment. In this way you can update your app without affecting other applications on the same server. ASP.NET vNext will let you deploy your own version of the .NET Framework on an app-by-app-basis.

MVC, Web API and Web Pages have been merged into one framework, called MVC 6. This will follow common programming approach between all these three i.e. a single programming model for Web sites and services.

ASP.NET vNext includes new cloud-optimized versions of MVC, Web API, Web Pages, SignalR, and Entity Framework. The advantage of using the Cloud Optimized Framework is that you can include a copy of the Core (or Mono) CLR with your website. You no longer have to upgrade .NET on the entire machine for the sake of one website. You can even have different versions of the CLR for different websites running side by side.

.NET vNext use the Roslyn compiler to compile code dynamically. You will be able to edit a code file, refresh the browser, and see the changes without rebuilding the project.

.NET vNext is open source and cross platform. Not only is Microsoft planning for cross-platform deployment, they are also enabling cross-platform development. Batch files for the major platforms such as OS X and Linux will be provided so that you can package and deploy ASP.NET vNext projects without needing Windows and Visual Studio.

MVC 6 has no dependency on System.Web since it was quite expensive. A typical HttpContext object graph can consume 30K of memory per request and working with small JSON-style requests this is very costly. With MVC 6 it is reduced to roughly 2K. The result is a leaner framework, with faster startup time and lower memory consumption.

ASP.NET vNext apps are cloud ready by design. Services such as session state and caching will adjust their behavior depending on hosting environment either. It is cloud or a traditional hosting environment. It uses dependency injection behind the scenes to provide your app with the correct implementation for these services for cloud or a traditional hosting environment. In this way, it will easy to move your app from on-premises to the cloud, since you need not to change your code.

vNext is host agnostic. You can host your app in IIS, or self-host in a custom process. (Web API 2 and SignalR 2 already support self-hosting; ASP.NET vNext brings this same capability to MVC.)

ASP.NET vNext has new project extension project.json to list all the dependencies for the application and astartup class in place of Global.asax.

Dependency injection is built into the framework. Now, you can use your preferred IoC container to register dependencies.

Cheap ASP.NET 4.5 Hosting

We’re a company that works differently to most. Value is what we output and help our customers achieve, not how much money we put in the bank. It’s not because we are altruistic. It’s based on an even simpler principle. "Do good things, and good things will come to you".

Success for us is something that is continually experienced, not something that is reached. For us it is all about the experience – more than the journey. Life is a continual experience. We see the Internet as being an incredible amplifier to the experience of life for all of us. It can help humanity come together to explode in knowledge exploration and discussion. It is continual enlightenment of new ideas, experiences, and passions

Author Link


Corporate Address (Location)

170 W 56th Street, Suite 121
New York, NY 10019
United States

Tag cloud

Sign in