Cheap and Reliable Hosting :: Routing in ASP.NET Web Form Application

IHostAzure.com | Cheap and Reliable ASP.NET Hosting. This article is not dedicated to the basics of routing and its various forms but we will implement the concept of routing in Web Form applications.

I hope you are familiar with routing in MVC applications or at least you know the basic concepts of routing. However, let’s explain routing in a few lines. The fact should be clear, this article is not dedicated to the basics of routing and its various forms but we will implement the concept of routing in Web Form applications.

Sometimes we see a misconception in developer’s minds (mostly young ones) that that routing is only possible in MVC applications. It’s not true in reality. The routing feature is a core concept of ASP.NET and since MVC is built on top of ASP.NET, we can use the concept. But I can say that (I hope most of you will agree with me) the concept of routing became popular in the era of MVC.

However, it does not matter whether the application is in MVC architecture or traditional Web Form application, we can use the concept of routing.

So, let’s create one Web Form application to implement the concept. Here I have created one project structure where I have created two directories called “Bill” and “Order” and kept two .aspx files in both of them. Depending on the route URL the .aspx file will be executed that we will see shortly.

Routing1

Now, add the following code in the Application_start() event of the Global.aspx page. We can see that we made two entries in the RouteTable which is nothing but a key/value collection.

protected void Application_Start(object sender, EventArgs e)
        {
            RouteTable.Routes.MapPageRoute(
                "CustomerOrder",
                "Customer/{id}/Order",
                "~/Order/CustomerOrder.aspx");
            RouteTable.Routes.MapPageRoute(
                "CustomerBill",
                "Customer/{id}/Bill",
                "~/Bill/CustomerBill.aspx");
        }

Let’s discuss the route entry a little bit. The mapping URL strecture will be like the following.

"Customer/{id}/Order", "~/Order/CustomerOrder.aspx"

The “Customer” part is constant in the requested URL and then we will expect a place holder value, here it is “id”. The ‘id” will represent the user’s “id” or something like a primary key. Then again we have kept the constant value which is “Bill” and if the URL pattern is like the following:

Customer/1/Order

Then it will invoke the “customerBill.aspx” page which is located under the “Bill” directory. The procedure is the same for the second entry of the route table.

Now, let’s implement our Order page . Have a look at the following

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

namespace WebApp.Order
{
    public class ClsCustomerOrder
    {
        Dictionary<int, string> Order = new Dictionary<int, string>();
        public ClsCustomerOrder()
        {
            Order.Add(1, "C# Book");
            Order.Add(2, "Java Book");
            Order.Add(3, "PHP Book");
        }
        public string GetOrder(int id)
        {
            return Order[id];
        }
    }

    public partial class CustomerOrder : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string []url = HttpContext.Current.Request.Url.AbsolutePath.Split('/');
            ClsCustomerOrder Order = new ClsCustomerOrder();
            Response.Write("Order by the customer is :-" + Order.GetOrder(Convert.ToInt32(url[2])));

        }
    }
}

 The implementation is very simple, in the page load we are capturing the current URL and from there we are extracting the user name then we are looking up in the dictionary (which is created on another class and working as a Model in this example) to find the user’s order.

Now, I know this Model implementation is not proper and in a real scenario the data may code from the DB or other persistent storage area but we have implemented it to make it simple.

Let’s browse the URL like below.

Routing2Oh, we are getting data from the dictionary and our routing is working fine.
Let’s implement the Billing page now. Here is the code for the Billing page which is very similar to the Order page.

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


namespace WebApp.Bill
{
    public class ClsCustomerBill
    {
        Dictionary<int, int> Order = new Dictionary<int, int>();
        public ClsCustomerBill()
        {
            Order.Add(1,1000);
            Order.Add(2,1500);
            Order.Add(3,2400);
        }
        public int GetOrder(int id)
        {
            return Order[id];
        }
    }
    public partial class CustomerBill : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string[] url = HttpContext.Current.Request.Url.AbsolutePath.Split('/');
            ClsCustomerBill Order = new ClsCustomerBill();
            Response.Write("Bill by the customer is :-" + Order.GetOrder(Convert.ToInt32(url[2])));
        }

    }
}

 We are now browsing below the URL and it will hit the “CustomerBilling.aspx” page and we are getting the following output.

Routing3

 

Conclusion

In this article we have implemented the concept of routing in Web Form applications. If you were not aware of the previous then I hope you have enjoyed the article. Happy learning.

Best ASP.NET Hosting Recommendation

ASPHostPortal.com

ASPHostPortal.com is the leading provider of Windows hosting and affordable ASP.NET Hosting. ASPHostPortal proudly working to help grow the backbone of the Internet, the millions of individuals, families, micro-businesses, small business, and fledgling online businesses. ASPHostPortal has ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch, ASPHostPortal guarantees the highest quality product, top security, and unshakeable reliability, carefully chose high-quality servers, networking, and infrastructure equipment to ensure the utmost reliability.

DiscountService.biz

DiscountService.biz is The Best and Cheap ASP.NET Hosting. DiscountService.biz was established to cater to an under served market in the hosting industry web hosting for customers who want excellent service. DiscountService.biz guarantees the highest quality product, top security, and unshakeable reliability, carefully chose high-quality servers, networking, and infrastructure equipment to ensure the utmost reliability. DiscountService.biz has ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch. DiscountService.biz is devoted to offering the best Windows hosting solution for you.

HostForLIFE.eu

HostForLIFE.eu guarantees 99.9% uptime for their professional ASP.NET hosting and actually implements the guarantee in practice. HostForLIFE.eu is the service are excellent and the features of the web hosting plan are even greater than many hosting. HostForLIFE.eu offer IT professionals more advanced features and the latest technology. HostForLIFE.eu has supported ASP.NET 5 hsoting,  Relibility, Stability and Performance of  servers remain and TOP priority. Even basic service plans are equipped with standard service level agreements for 99.99% uptime. Advanced options raise the bar to 99.99%. HostForLIFE.eu revolutionized hosting with Plesk Control Panel, a Web-based interface that provides customers with 24×7 access to their server and site configuration tools.

Cheap And Reliable Hosting :: ASPHostPortal VS DiscountASP.NET Cheap And Reliable ASP.NET

ASP.NET is a web application framework developed and marketed by Microsoft to allow programmers to build dynamic web sites. It you to use a full featured programming language such as C# or VB.NET to build web applications easily. Today many companies who want to build dynamic websites with a lot of features. ASP.NET provides a set of web development models that include services that are important to the developers of building web applications .

To Selecting a Cheap and reliable ASP.NET Hosting, it really is fairly crucial which the hosting remedy contains the most recent and most stable .NET framework like ASP.NET 2/3.5SP1/5 that can assure people run any plans, and avoid compatible concerns. In this post, we’ll supply you with the low-cost and cheap and reliable  ASP.NET Hosting.
To discover the very Best cheap and reliable ASP.NET Hosting,  we’ve got to know exactly what are criterias which make a hosting organization turned the most effective ASP.NET Hosting. Right now, we’ll talk about concerning the cheap and reliable  ASP.NET Hosting by comparing the standard of two cheap and reliable ASP.NET Hosting company. That is ASPHostPortal and DiscountASP.NET.


ASPHostPortal.com
Starting $1.00/Month
ASP.NET 5.6.3 New Version
Yes
PHP / mySQL 5 New Version
Yes
SQL Server 2014 NewVersion
Yes
Uptime Guarantee
Yes
Trial Available
Yes
IIS 7.5/8/8.5 Support
Yes
United States (US) Server
Yes
European-based Server
Yes
Asia-based Server
Yes
Control Panel
Plesk Panel
Money Back Guarantee
30 Days
DiscountASP.NET
Starting from $10.0/month
OS
Windows 2012
IIS
8.0
Trust Level
Full
Application Pool
Dedicated
Classic ASP
Yes
ASP.NET
2/3.5SP1/4.5
ASP.NET MVC
2/3/4
Silverlight
4/5
MSSQL
2012
MSSQL Usage
$5/mo
 
 


ASPHostPortal

 ryt

ASPHostPortal is really cheap and reliable ASP.NET Hosting. They host web sites in several data center locations. Their info facilities are strategically positioned across the country to offer their consumers with all the maximum levels of availability, services and help within the industry.


Pricing

ASPHostPortal pricing is cheap and reliable hosting very competitive a hosting plan goes for as low as $1/month per month. Its really very cheap and reliable ASP.NET HostingASPHostPortal provides one of the Best Cheap And Reliable ASP.NET hosting in the industry for its affordable price, rich feature, professional customer support, and high reliability. It’s highly recommended for ASP.NET developers, business owners and anyone who plan to build a web site based on ASP.NET.

Reability

ASPHostPortal exerts to providing satisfying uptime and this hosting provider guarantees 99.9% uptime. We perform 24/7 network monitoring, firewall management, and anti-malware monitoring

Expert Support Team

ASPHostPortal Expert Support Team is very friendly. you can ask all your problems to them. They are always ready to help you 24/7/365. they will never fall sleep, and 30-Day Money Back Guarantee.

ASPHostPortal Windows Best, Cheap and Reliable  ASP.NET Hosting offers the power and flexibility of Parallels Plesk Panel, IIS (Internet Information Services), Microsoft SQL Server 2014/ 2012/2008 R2, and a wide variety of other hosting features such as ASP and ASP.NET for a cheapest. This is their hosting quality.


DiscountASP.NET

Untitled

DiscountASP.NET provides one of the cheap and reliable  ASP.NET hosting in the industry for its affordable price, rich feature, professional customer support, and high reliability. It’s highly recommended for ASP.NET developers, business owners and anyone who plan to build a web site based on ASP.NET.  Started at only $10.0 per month.


Windows Hosting Experts

Given the scale of their environment, they have recruited and developed some of the best talent in the hosting technology that you are using. their team is strong because of the experience and talents of the individuals who make up DiscountASP.NET

Guaranteed UpTime

DiscountASP.NET is a reliable ASP.NET hosting service provider that guarantees 99.9% uptime for their ASP.NET hosting service.

Fastest Network

Every facet of their network infrastructure scales to gigabit speeds with no single point of failure. Since they built it theirselves, they made it ideal. They designed the network. They designed the server arrangement from the software to the outer casing.


Conclusion

Although both of ASPHostPortal and DiscountASP.NET offer various ASP.NET hosting plans, with a lot of feature are same from each other. From the comparison above, it is apparent that ASPHostPortal is a more cheap and reliable ASP.NET Hosting favorable choice due to its more cost-effective.