All About ASP.NET and ASP.NET Core 2 Hosting BLOG

Tutorial and Articles about ASP.NET and the latest ASP.NET Core

ASP.NET 4.5.1 Hosting:: How to Integrate Your ASP.NET Apps in Facebook

clock May 12, 2014 11:27 by author Ben

In this article I’m going to explain how to integrate ASP.NET applications in facebook.
Facebook has provided functionality that extends the Facebook Platform to any website that wants to integrate Facebook APIs for user authentication, sharing website content with friends, and publishing feed stories to generate traffic.
Here I’ll show you how to integrate ASP.NET Apps in Facebook.  Please follow the steps given below.

Setting up Facebook App

  • To create facebook app click on Developer section
  • Click on Set up New App button.
  • Agree Facebook terms and click on Create App
  • Put Security Check keywords.
  • Click on Submit.
  • Fill basic information about app

  • Click on Facebook Integration tab.
  • Put Name of Canvas page.
  • Before putting URL of webpage of your website, I want to show how your page can get callback from facebook app. So first we create webpage in our website:
  • Create website in Visual studio.
  • Add reference of Facebook.dll from “C:\Program Files\Coding4Fun\Facebook\Binaries”. This dll will be placed after installing Facebook Developer kit on your machine.
  • Create instance of FacebookService object. you can copy facebook app api key and secret key from application page on facebook in source code.

put above values in FACEBOOK_API_KEY and FACEBOOK_SECRET constants respectively.
you can get user_id of facebook who requested this application by calling
string userId = Session["Facebook_userId"] as String;

you can also get many information about user like name, sex, location,friends etc.
User usr=_fbService.GetUserInfo();

Source Code:

using System;
using Facebook;
public partial class Facebook_ConnectFacebook : System.Web.UI.Page
    Facebook.Components.FacebookService _fbService = new Facebook.Components.FacebookService();
    private const string FACEBOOK_API_KEY = "191856207506775";
    private const string FACEBOOK_SECRET = "820c0b05b14a09365e072c8d37a8c49f";

    protected void Page_Load(object sender, EventArgs e)
        _fbService.ApplicationKey = FACEBOOK_API_KEY; _fbService.Secret = FACEBOOK_SECRET;
        _fbService.IsDesktopApplication = false;
        string sessionKey = Session["Facebook_session_key"] as String;
        string userId = Session["Facebook_userId"] as String;
    // When the user uses the Facebook login page, the redirect back here
    // will will have the auth_token in the query params
    string authToken = Request.QueryString["auth_token"];
    // We have already established a session on behalf of this user
        if (!String.IsNullOrEmpty(sessionKey))
            _fbService.SessionKey = sessionKey; _fbService.UserId = userId;
        // This will be executed when Facebook login redirects to our page        
        else if (!String.IsNullOrEmpty(authToken))
            Session["Facebook_session_key"] = _fbService.SessionKey;
            Session["Facebook_userId"] = _fbService.UserId;
            Session["Facebook_session_expires"] = _fbService.SessionExpires;
        // Need to login        
            Response.Redirect(@"" + _fbService.ApplicationKey + @"&v=1.0\");

        User usr = _fbService.GetUserInfo();
        string t = string.Format("User Name:{0}, Sex:{1}, Location: {2}", usr.Name, usr.Sex, usr.CurrentLocation.City);

Best and Recommended ASP.NET 4.5.1 Hosting Solution

The next version of the .NET Framework is .NET 4.5.1. It has been published as Preview version as announced yesterday during the BUILD conference. The new update builds on top of .NET 4.5 and includes new features such as async-aware debugging, ADO.NET idle connection resiliency, and ASP.NET app suspension., a leading innovator in Windows Server hosting, announces a Free Trial ASP.NET 4.5.1 hosting on Windows Server 2012 R2 for the developer community.

ASP.Net Hosting – :: How to Use NumericUpDownExtender in ASP.Net AJAX

clock February 24, 2014 05:09 by author Diego

NumericUpDown is an ASP.NET AJAX extender that can be attached to an ASP.NET TextBox control to add "up" and "down" buttons that increment and decrement the value in the TextBox. The increment and decrement can be simple +1/-1 arithmetic, they can cycle through a provided list of values (like the months of the year), or they can call a Web Service to determine the next value. Page authors can also provide custom images to be used instead of the default up/down button graphics. In this article, I will show you step by step procedure, how to use a Up Down Extender

In ASP.NET using Visual Studio 2005 or Visual Studio 2008.

Step 1 : Open Visual Studio.

  • Go to File->New->WebSite
  • Select ASP.NET WebSite

Step 2 :

Under Visual Studio Installed Template-> Choose ASP.NET WEB SITE -> Choose File System from the location combo box -> Set the path by the browse button - > Choose the language from the Language ComboBox (Visual C# , Visual Basic , J #)

  • Choose Visual C#

Step 3 :

Click on the OK Button.
This is the source code window :

Step 4 :
See here is a tab named Design in the bottom of this page. Click on this tab and you will see a blank web page where you can drag any control from the toolbox (which is in the left side of this window).

Step 5 :
Now drag some controls under the AJAX Extensions. First control you are going to drag and drop on the page is - Script Manager.

  • first add a tag on the top of your source code window:
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
  • Under the form tag,NumericUpDownExtender control

Step 6:

Now run the application by pressing ctrl +  F5.

Step 7 :

When you run the Up Down Extender will seem like this...


ASP.NET 4.0 Hosting - :: Initialize assemblies using PreApplicationStartMethod for ASP.NET 4.0 Application

clock December 20, 2013 05:44 by author Robert

Sometimes your ASP.NET application needs to hook up some code before even the Application is started. Assemblies supports a custom attribute called PreApplicationStartMethod which can be applied to any assembly that should be loaded to your ASP.NET application, and the ASP.NET engine will call the method you specify within it before actually running any of code defined in the application.

Lets discuss how to use it using Steps :

1. Add an assembly to an application and add this custom attribute to the AssemblyInfo.cs. Remember, the method you speicify for initialize should be public static void method without any argument. Lets define a method Initialize. You need to write :

[assembly:PreApplicationStartMethod(typeof(MyInitializer.InitializeType), "InitializeApp")]

2. After you define this to an assembly you need to add some code inside InitializeType.InitializeApp method within the assembly.

public static class InitializeType
    public static void InitializeApp()
          // Initialize application


3. You must reference this class library so that when the application starts and ASP.NET starts loading the dependent assemblies, it will call the method InitializeApp automatically.


Even though you can use this attribute easily, you should be aware that you can define these kind of method in all of your assemblies that you reference, but there is no guarantee in what order each of the method to be called. Hence it is recommended to define this method to be isolated and without side effect of other dependent assemblies.

The method InitializeApp will be called way before the Application_start event or even before the App_code is compiled.

This attribute is mainly used to write code for registering assemblies or build providers.


Free ASP.NET 4.5.1 Hosting - ASPHostPortal :: How To Create and Delete Cookies Using ASP.NET

clock December 10, 2013 06:24 by author Ben

Cookies is a small piece of information stored on the client machine. This file is located on client machines "C:\Document and Settings\Currently_Login user\Cookie" path.  Its is used to store user preference information like Username, Password,City and PhoneNo etc on client machines that you created in ASP.NET.
Cookies could be stolen by hackers to gain access to a victim's web account. Even cookies are not software and they cannot be programmed like normal executable applications. Cookies cannot carry viruses and cannot install malware on the host computer. However, they can be used by spyware to track user's browsing activities.

How to create a cookie?
There are many ways to create cookies, I am going to outline some of them below:
Example 1:
HttpCookie userInfo = new HttpCookie("userInfo");
userInfo["UserName"] = "Annathurai";
userInfo["UserColor"] = "Black";
userInfo.Expires.Add(new TimeSpan(0, 1, 0));

Example 2:
Response.Cookies["userName"].Value = "Annathurai";
Response.Cookies["userColor"].Value = "Black";

How to delete cookie?
Now look at the code given below which will delete cookies.
Example 1:
string User_Name = string.Empty;
string User_Color = string.Empty;
User_Name = Request.Cookies["userName"].Value;
User_Color = Request.Cookies["userColor"].Value;

Example 2:
string User_name = string.Empty;
string User_color = string.Empty;
HttpCookie reqCookies = Request.Cookies["userInfo"];
if (reqCookies != null)
User_name = reqCookies["UserName"].ToString();
User_color = reqCookies["UserColor"].ToString();

When we make request from client to web server, the web server process the request and give the lot of information with big pockets  which will have Header information, Metadata, cookies etc., Then repose object can do all the things with browser.

Cookie's common property:

  • Domain => Which is used to associate cookies to domain.
  • Secure  => We can enable secure cookie to set true(HTTPs).
  • Value    => We can manipulate individual cookie.
  • Values  => We can manipulate cookies with key/value pair.
  • Expires => Which is used to set expire date for the cookies.

Advantages of Cookie:

  • Its clear text so user can able to read it.
  • We can store user preference information on the client machine.
  • Its easy way to maintain.
  • Fast accessing.
  • Disadvantages of Cookie
  • If user clear cookie information we can't get it back.
  • No security.
  • Each request will have cookie information with page.

How to clear the cookie information?
we can clear cookie information from client machine on cookie folder

To set expires to cookie object
userInfo.Expires = DateTime.Now.AddHours(1);
It will clear the cookie with one hour duration.

Our Special ASP.NET 4.5.1 Hosting Complete Features

  1. 24/7 Monitoring, We do 24/7 monitoring of your ASP.NET to make sure that we proactively kill any trouble. This helps to ensure maximum uptime and performance.
  2. Easy-to-use service (1-click installs), gives you access to all SimpleScripts features, provides easy one-click installation and management of all popular applications.
  3. Fast and Secure Server, Our powerfull servers are especially optimized and ensure the best ASP.NET 4.5.1 performance. We have best data centers on three continent and unique account isolation for security.
  4. Daily Backup Service, We realise that your website is very important to your business and hence, we never ever forget to create a daily backup. Your database and website are backup every night into a permanent remote tape drive to ensure that they are always safe and secure. The backup is always ready and available anytime you need it.

ASP.NET 4.5 Hosting - :: Asynchronous WCF service calls using .NET Framework 4.5

clock October 10, 2013 06:22 by author Ben

The Windows Communication Foundation (WCF) is an application programming interface in the .NET Framework for building connected, service-oriented applications. A WCF client has two ways to access the functions provided by WCF services. They are synchronous and asynchronous WCF calls. This article i wanna tell you how to asynchronous WCF service calls using .NET Framework 4.5. To demonstrate examples, I am using Windows 7 and Visual Studio 2010.

1. Open Visual Studio . It will create a Web service called MyAsync.asmx with a sample web method inside.

You can see the code snippet of the web method below: 

public string MyTestAsynchronousMethod(string strName, int
  return "Hei..." + strName + "Iam Called Asynchronously"; 

2. And also we create a consuming ASP.NET web application that looks like the below screenshot.

Now the only thing we have to do is call the web service in the button click event.

To call the application on the button click event we have to create a proxy. As all of you know we can create a proxy using WSDL.EXE and also by adding a web reference to the consuming application. Here I am going to use the second approach, i.e., using service reference for ease.

Right click the consuming web application, go to the Add Service Reference option, Then go ahead with adding the service reference in your consuming application. I have added a web reference in the consuming application with name MyProxy.

So we are all set to call the service from our button click.

In the asynchronous button click,I am going to create the proxy class object and looking at the intelisense, we can see that there are mainly three things related to our web method which we have created. 1 event and two methods,one with an async augment.

Here we are going to use the event called MyTestAsynchronousMethodCompleated and the web method MyTestAsynchronousMethodAsync.

You might think that from where the web method MyTestAsynchronousMethodAsync does and the event MyTestAsynchronousMethodCompleated came from, right ?
The answer is it will come by default while creating the proxy of the web service.

The web method MyTestAsynchronousMethodAsync is the hero who makes the asynchronous call happen and the event MyTestAsynchronousMethodCompleated is the supporting actor of the hero.

You can see the event and the method in the below snapshot.

3. The next thing we have to do is to plumb the event. As I mentioned earlier, the event is responsible to return the result after the execution of the web service method.  So I am going to set a label in our consuming application in such a way that it will display the returned string from the web service method call.
For that purpose I have added an event handler for that event. Visual Studio will create the event handler stub automatically for us. Just type += next to the event which we have and hit Tab key twice in your keyboard. You have got your event handler stub with the arguments and the parameters set. The only thing you have to do is write the business logic inside the event handler stub. That Visual Studio doesn't know, I mean your business logic.
This is the code :

4. You can see a property called Result in the event argument. That’s the property that gives you the web method executed Result, Error etc., in string format, it’s not the service method itself as before.
So let’s go and implement the logic in the stub by assigning the result to the label text property (you can see this in the below snapshot). We are going to call the second web method which is generated automatically.

namespace AsyncConsumer
    public partial class _Default : System.Web.UI.Page
        Stopwatch objSW = new Stopwatch();
        protected void Page_Load(object sender, EventArgs e)
        protected void BtnAsync_Click(object sender, EventArgs e)
            MyProxy.MyAsync objProxy = new MyProxy.MyAsync();
            objProxy.MyTestAsynchronousMethodCompleted += 
              new MyProxy.MyTestAsynchronousMethodCompletedEventHandler(
            lblExecTime.Text = "Total Execution Time :" + 
              objSW.ElapsedMilliseconds.ToString() + " Milliseconds";
        void objProxy_MyTestAsynchronousMethodCompleted(object sender, 
             MyProxy.MyTestAsynchronousMethodCompletedEventArgs e)
            lblResult.Text = e.Result;
        private void DoSomeLongJob()

5. I have added a method called DoSomeLongJob(). Which makes the thread to wait for 5 seconds for the consuming application and a Label to display the execution time.The above is the complete code snippet which we have done.
Let’s see the execution of our application.

What would be the result and execution time?
In a normal case this will take approximately 7 seconds delay, that is 2 seconds which we have given, and the 5 seconds of the DoSomeLongJob();

Let’s see how long will it take. 

Ooopsss!!! Unfortunately or fortunately I got an exception like below while clicking the button:

6. Did you notice the marked portion in the exception?
Yes, we have to add and set the Async attribute to true in the Page directive of the page in which we are planning to have any asynchronous web service method call. Otherwise it’s not possible. Let’s go and set it.

After setting the Async attribute the directive will be like:

7. And the last, reload your page.

Free ASP.NET hosting - :: Proudly Announces Free Trial Windows ASP.NET Hosting

clock October 3, 2013 10:11 by author Ben is a premier Windows and ASP.NET Web hosting company that specializes in Windows and ASP.NET-based hosting. We proudly announces 7 Day Free Trial Windows and ASP.NET Hosting to all new customers. The intention of this FREE TRIAL service is to give our customers a "feel and touch" of our system. This free trial is offered for the next 7 days and at anytime, our customers can always cancel the service.

The 7 Day Free Trial is available with the following features:

- Unlimited Domains
- 5 GB Disk Space
- 60 GB of Bandwidth
- 2 MS SQL Database
- Unlimited Email Account
- Support ASP.NET 4.5
- Support MVC 4.0
- Support SQL Server 2012
- Free Installations of ASP.NET And PHP Applications believes that all customers should be given a free trial before buying into a service and with such approach, customers are confident that the product / service that they choose is not faulty or wrong. Even we provide free trial service for 7 days, we always provide superior 24/7 customer service, 99,9% uptime guarantee on our world class data center. On this free trial service, our customer still can choose from our three different data centre locations, namely Singapore, United States and Amsterdam (The Netherlands)

Anyone is welcome to come and try us before they decide whether or not they want to buy. If the service does not meet your expectations, our customer can simply cancel before the end of the free trial period.

For all the details of packages available visit

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, ASPHostPortal 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.

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

 photo ahp banner aspnet-01_zps87l92lcl.png


Corporate Address (Location)

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

Tag cloud

Sign in