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 with :: How to Increase The Overall Performance of ASP.NET 4.5.1 in your App

clock October 1, 2014 07:23 by author Ben

ASP.NET is really a framework for creating net applications created by Microsoft. Initially the technologies. NET is the successor of ASP which is also a computer software product from Microsoft. With .NET ASP gives a platform for developers to design and create dynamic websites and net portals.

You will find certain items that ought to be regarded as when improving the performance from the application in developing a net application. Here are a few of the tips to improve the performance of ASP.NET 4.5.1:

Turn off Session State
Disable session state if you do not need, as this can improve the all round efficiency. By default the session state is always active. However, you'll be able to disable session state for any specific pages.

Turn off Tracing
If tracing is enabled, tracing will add a whole lot of overhead in producing applications. Though tracing is actually a useful function inside the development because it enables developers to track and trace application sequence, tracing may be turned off, unless you want to monitor the trace logging.

Avoid Page Validation Server (Steer clear of Server-side Validation)
Within this case, must be attempted use of client-side validation, not the server side. Server-side validation will consume a lot of sources around the server which can have an effect on application efficiency.

Stay away from Exceptions (Avoid Exceptions)
Exceptions may be 1 of the biggest resource eater which resulted within the lower of web applications and windows applications. Therefore, it is much better to prevent the use and handling of exceptions which can be not beneficial.

Avoid frequent connections for the database (Steer clear of Frequent Calls to Database)
Connections are frequently made for the database can devote time response and resources (resources). This can be avoided by utilizing batch processing. Producing the minimum database connection as a connection is opened and not closed, may cause efficiency slowdown.

Stay away from utilizing Recursive Functions and Nested Loops
To improve application performance, attempt to always steer clear of utilizing nested loops and recursive functions simply because these functions consume a whole lot of memory.

Turn off the View State

In ASP.NET, the default view state will probably be active and will slow down the website. So if you don't use a kind postback, it's much better to disable view state.

Use Caching
Web page caching could be employed to get a particular period of time and towards the required duration will not visit the server and are served from the cache. In the case of static internet pages and dynamic, Partial Caching [Fragment Caching] may be utilized to break into a couple of pages a user control.

Free Trial ASP.NET 4.5.1 Hosting with :: How to Send Bulk Email Using ASP.Net 4.5

clock April 3, 2014 12:14 by author Kenny

In this article I’m going to explain about how to send bulk email using ASP.Net 4.5. Bulk email software is software that is used to send email in large quantities. Bulk mail broadly refers to mail that is mailed and processed in bulk at reduced rates. The term does not denote any particular purpose for the mail; but in general usage is synonymous with "junk mail". This tutorial we will use ASP.NET Web Page for provide the user interface for your Web applications, Grid View for enables you to select, sort, and edit values of a data source in a table where each column represents a field and each row represents a record, HTML Email Templates and Gmail SMTP Mail Server.

Let’s start to try this tutorial, for the first step you must create a new project.
Click "File" -> "New" -> choose "Project..." and then select web "ASP .Net Web Forms Application". Name it as "Bulk Email".
And now let’s see in the Design page “Default.aspx” design the web page as in the following screen:

This is code for Design Source (Default.aspx):

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="BulkEmail._Default" %>
<asp:Content runat="server" ID="FeaturedContent" ContentPlaceHolderID="FeaturedContent">
    <section class="featured">
        <div class="content-wrapper">
            <hgroup class="title">              
                <h2>Send Bulk email using</h2>
            <p>To learn more about ASP.NET
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
       <h3>We suggest the following:</h3>
    <asp:Panel ID="Panel1" runat="server" Width="100%" ScrollBars="Horizontal">
       <asp:Button ID="btnBind" runat="server" Text="View" OnClick="btnBind_Click" /> <asp:Label
ID="Label1" runat="server" Font-Bold="true" ForeColor="Green" Text="Total
</asp:Label><asp:Label ID="lbltotalcount" runat="server" ForeColor="Red" Font
Size="Larger"></asp:Label> </p>
        <asp:Button ID="btnSend" runat="server" Text="Send" OnClick="btnSend_Click" />
        <asp:GridView ID="grvCustomers" runat="server"></asp:GridView>

In the Web.config file create the connection string as:

<add name="ConnectionString"connectionString="Server=localhost;userid=root;password=;Database=

In the code behind file (Default.aspx.cs) write the code as:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

//Using namespaces 
using MySql.Data.MySqlClient;
using System.Configuration;
using System.Text;
using System.Net;
using System.Net.Mail;
using System.Data;

namespace BulkEmail
    public partial class _Default : Page
        #region MySqlConnection Connection
        MySqlConnection conn = new

        protected void Page_Load(object sender, EventArgs e)
                if (!Page.IsPostBack)

            catch (Exception ex)
        #region show message
        /// <summary>
        /// This function is used for show message.
        /// </summary>
        /// <param name="msg"></param>
        void ShowMessage(string msg)
            ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script
language='javascript'>alert('" + msg + "');</script>");
        #region Bind Data
        /// <summary>
        /// This display the data fetched from the table using MySQLCommand,DataSet and
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnBind_Click(object sender, EventArgs e)
                MySqlCommand cmd = new MySqlCommand("Select
CustomerID,ContactName,Address,Phone,Email from customers", conn);
                MySqlDataAdapter adp = new MySqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                grvCustomers.DataSource = ds;
                lbltotalcount.Text = grvCustomers.Rows.Count.ToString();
            catch (MySqlException ex)

            btnBind.Visible = false;
        #region Bulk email,GridView,gmail
        /// <summary>
        /// this code used to Send Bulk email 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSend_Click(object sender, EventArgs e)
                lbltotalcount.Text = string.Empty;
                foreach (GridViewRow grow in grvCustomers.Rows)
                    string strCustomerID = grow.Cells[0].Text.Trim();
                    string strContactName = grow.Cells[1].Text.Trim();
                    string strAddress = grow.Cells[2].Text.Trim();
                    string strPhone = grow.Cells[3].Text.Trim();
                    string strEmail = grow.Cells[4].Text.Trim();               

                    string filename = Server.MapPath("~/Event.html");
                    string mailbody = System.IO.File.ReadAllText(filename);
                    mailbody = mailbody.Replace("##NAME##", strContactName);
                    string to = strEmail;
                    string from = "";
                    MailMessage message = new MailMessage(from, to);
                    message.Subject = "Auto Response Email";
                    message.Body = mailbody;
                    message.BodyEncoding = Encoding.UTF8;
                    message.IsBodyHtml = true;
                    SmtpClient client = new SmtpClient("", 587);
                    System.Net.NetworkCredential basicCredential = newSystem.Net.NetworkCredential("", "Password");
                    client.EnableSsl = true;
                    client.UseDefaultCredentials = true;
                    client.Credentials = basicCredential;
                        ShowMessage("Email Sending successfully...!" + strContactName + " &nbsp;");                                           
                    catch (Exception ex)
            catch (MySqlException ex)

Finally, Bulk Sending an E-Mail Using ASP.NET 4.5 with HTML Email Templates and Gmail SMTP Mail Server.

ASP.NET 4.5.1 Hosting with :: Capture images using web camera in ASP.NET 4.5.1

clock March 25, 2014 09:11 by author Kenny

In this article, i'm going to explain about how to integrate a webcam into your web application using ASP.NET 4.5.1. A web camera can capture images at the server end and a web page can display them. It’s very simple for integrate a webcam and capture images in your website that using ASP.NET 4.5.1.

Before it, make sure that your device has Latest Flash player and Web camera.
Let's following these steps:

First, copy the “WebcamResources” into your new application.
After that, add the following code in to your Default.aspx page:
<object width="450" height="200"param name="movie1" value="WebcamResources/save_picture.swf"

embed src="WebcamResources/save_picture.swf" width="45
height="200" >

This code will place your Flash object into your web page, used to capture the images from the web cam.
Add one more page there with the name ImageConversions.aspx.
Add the following code into ImageConversion.aspx at the page load event:
string str_Photo = Request.Form["image_Data"]; //Get the image from flash file
byte[] photo = Convert.FromBase64String(str_Photo);
FileStream f_s = new FileStream("C:\\capture.jpg", FileMode.OpenOrCreate, FileAccess.Write);
BinaryWriter b_r = new BinaryWriter(f_s);

The above code will convert the bytes to an image and will save the image in the c drive.

ASP.NET 4.5.1 - with :: SEO friendly URLs with ASP.NET

clock February 26, 2014 06:51 by author Kenny

Search engines like human-readable URLs with keywords in it, and hesitate to respect messy URLs with a lot of query-string parameters. So, to make our ASP.NET database-driven website SEO-friendly we have to get rid of our complex URLs.

SEO or Search Engine Optimization is the process of affecting the visibility of a website or a web page in a search engine's "natural" or un-paid ("organic") search results. In general, the earlier (or higher ranked on the search results page), and more frequently a site appears in the search results list, the more visitors it will receive from the search engine's users. SEO may target different kinds of search, including image search, local search, video search, academic search, news search and industry-specific vertical search engines.

Solution 1: Fake pages and "Server.Transfer".
As you can see the two URLs above point to the same page. Basically it is the same page and it works like this: the page mailjet-newsletter-software.aspx contains no code at all and performs a Server.Transfer (aka server-side redirect) to product.aspx like this:
That's it. We have one "product.aspx" page which expects a "ProductID" parameter and a lot of "fake pages" with SEO-friendly names like firstproduct.aspx, secondproduct.aspx etc., which simply perform a Server.Transfer to the "product.aspx" with the right ProductID.

Simple, isn't it?

But this solution requires a lot of hard-coding - we will have to create all these fake pages and add a Server.Transfer command. So let's go a little further: we will create one base class for all our "fake pages" and add a record to the "tblProducts" table in the database:

Now we have to create our fake pages, inherit them all from the ProductPage class and voi la - that's it! We can also optionally remove all the HTML-code from the aspx-files, leaving the "Page" directive only.

Solution 2: Virtual Pages.

This method is pretty similar, except that we don't need to create any pages at all. Instead, we will add an HttpModule, which intercepts HTTP requests, and the user requests a non-existent page, performs a Rewrite operation. First we will create our HttpModule:

Now we have to register our HttpModule in the web.config:

<add type="URLRewrite.ProductPageModule, URLRewrite" name="ProductPageModule" />

ASP.NET 4.5.1 - with :: How to Create Dynamic DropDownLists in ASP.NET 4.5.1

clock February 26, 2014 06:23 by author Kenny

Now i will tell you how to create Dynamic DropDownLists in ASP.NET 4.5.1


1. Create dropdownlist dynamically with autopostback property true
2. Keep dropdownlist during postback
3. Maintain selected value during postback.
Here is the sample for this.

In aspx page:
id="form1" runat="server">


        <asp:Table ID="tbl" runat="server">


        <asp:Button ID="btnSet" runat="server" Text="Button" onclick="btnSet_Click" /> </div>


To Create Dynamic Dropdownlist:

void Page_Load(object sender, EventArgs e)


    if (!Page.IsPostBack)





    private void CreateDynamicTable()


        // Fetch the number of Rows and Columns for the table

        // using the properties

        int tblRows = 3;

        int tblCols = 3;

        // Now iterate through the table and add your controls

        for (int i = 0; i < tblRows; i++)


            TableRow tr = new TableRow();

            for (int j = 0; j < tblCols; j++)


                TableCell tc = new TableCell();

                DropDownList ddl = new DropDownList();

                ddl.ID = "ddl-" + i.ToString() + "-" + j.ToString();

                for (int k = 0; k < 5; k++)


                    ddl.Items.Add(new ListItem("item-"+k.ToString(),k.ToString())); 


                ddl.AutoPostBack = true;

                ddl.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged);

                // Add the control to the TableCell


                // Add the TableCell to the TableRow



            // Add the TableRow to the Table


            tbl.EnableViewState = true;

            ViewState["tbl"] = true;



protected void ddl_SelectedIndexChanged(object sender, EventArgs e)


    // what you want to perform    


To retrieve value on button click:

void btnSet_Click(object sender, EventArgs e)


        foreach (TableRow tr in tbl.Controls )


            foreach (TableCell tc in tr.Controls)


                if (tc.Controls[0] is DropDownList)


                    Response.Write(((DropDownList)tc.Controls[0]).SelectedItem.Text+" ");        





Right Now, No output because dynamic controls are lost in postback then what to do.

So we need to save dynamic controls value and generate dynamic controls again.we need to maintain viewstate.

override object SaveViewState()


    object[] newViewState = new object[2];

    List<string> txtValues = new List<string>();

    foreach (TableRow row in tbl.Controls)


        foreach (TableCell cell in row.Controls)


            if (cell.Controls[0] is DropDownList)






    newViewState[0] = txtValues.ToArray();

    newViewState[1] = base.SaveViewState();

    return newViewState;


protected override void LoadViewState(object savedState)


    //if we can identify the custom view state as defined in the override for SaveViewState

    if (savedState is object[] && ((object[])savedState).Length == 2 && ((object[])savedState)[0] is string[])


        object[] newViewState = (object[])savedState;

        string[] txtValues = (string[])(newViewState[0]);

        if (txtValues.Length > 0)


            //re-load tables


            int i = 0;

            foreach (TableRow row in tbl.Controls)


                foreach (TableCell cell in row.Controls)


                    if (cell.Controls[0] is DropDownList && i < txtValues.Length)


                        ((DropDownList)cell.Controls[0]).SelectedIndex = Convert.ToInt32(txtValues[i++]);





        //load the ViewState normally








ASP.NET 4.5.1- with :: How to Create Barcodes using ASP.NET App

clock February 26, 2014 05:09 by author Kenny

To create barcodes we will use ASP.NET web services. Not only that, we will also create Windows Forms and Console application to request barcode image.

What is The Benefits?

Well, web services provide a major benefit in integrating the software with external applications. With standardized request/response model, any client application that can utilize XML web service can benefit from it.Below is the brief visual representation of the barcode service. The clients do not need to refer to Aspose.BarCode for .NET. They will just send 2 string values (codetext and symbology) and will get the barcode image (byte array) from service.

Barcode Web Service
Now, open Microsoft Visual Studio. Create a new project of type “ASP.NET Web Service Application”. Name the project as “BarCodeService”. Add reference to the following .NET assemblies.

  1. System.Drawing from .NET tab of “Add Reference” dialog box
  2. Aspose.BarCode.

Browse to the location where Aspose.BarCode for .NET is installed and select. Visual Studio adds a default class “Service1” to the Web Service project in Service1.asmx file.
Open it and add the following method to this class.

The web method needs the following two parameters from client:

  1. Codetext
  2. Symbology

These parameters are of String type. The parameters are passed to the BarCodeBuilder class, which then creates the barcode and sends the barcode image in the form of byte array to the client.
This web method can be called by any kind of application that can consume a web service.

Consume Web Service from Windows Forms Application

Open Visual Studio and create a new project of type “Windows Application”. Name the project as “ GetBarCodeWinForms ”. Add reference to the web service by right clicking on “References” and then choosing “Add Service Reference” from the context menu. Type the address of web service or discover it. After getting the correct service, give “BarCodeService” in the Namespace and click on “Ok” button to add the reference.

Design the forms as follows.

It contains the following controls:

  1. Textbox: Input codetext from user
  2. Combobox: Input symbology type from user
  3. Button: Call web service
  4. Picturebox: Display the barcode image

Write the following code on click event of the button.

Run the application, specify some values and click on the “Get Barcode” button. The application will consume the barcode web service and get the barcode image from it. The image will then be displayed on the form as below.

Consume Web Service from a Console Application

Create a new project in Visual Studio and choose “Console Application” in project type. Name the project as “ GetBarCodeConsole ”. Add the reference to the barcode service, just as we gave above in the winforms application.Write the below code in the main() method.

Run the application, it will consume the barcode web service, get barcode image and save the image locally to disk.


Aspose.BarCode for .NET can easily be used in ASP.NET web services to generate the barcodes and serve the barcode image to various clients.

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