ASP.NET 4.5 and ASP.NET Core 1 Hosting BLOG

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

ASP.NET 4.5 Free Trial Hosting - How to Build Website Using A Simple AJAX Driven Website with jQuery + PHP

clock October 29, 2013 07:11 by author Mike

AJAX is abbrieviated from Asynchrounous javascript and XML. It's not a new technology, but the implementation of a group of technologies to achieve a seamless interaction between client and server.

Typically, xhtml and css to present the information, javascript is used to handle user interactions, and a server side language to perform the users' requests (and normally return data in XML format, in this tutorial, we won't do that), and it all is happening in the background using the Javascript XMLHttpRequest. Javascript plays a main role tie all these technologies together and create the asynchronous interaction between client ans server.

AHAH (Asynchrounous HTML and HTTP) is a subset of AJAX which is another technique, Inspite of retreiving XML, AHAH is retreiving HTML content. Both of them are basically the same, the only difference is the content it returns. Generally, most people will simply call it AJAX, but technically, we should call it AHAH. In this tutorial, AHAH is used.

The Goodies:
- Reduce connections and bandwidth to the server, images, scripts, stylesheets only need to be downloaded once
- Reduce loading timew. User doesnt have to load pages again and again, it all happens in a same page!
- Increase responsiveness and end user experiences.

The Badies:

- Browser Back button. AJAX web pages cannot connect with browser history engine. If you clicked on back button, you can't navigate those AJAX content.
- Bookmark will not work on AJAX webpages. Due to the dynamic content, you might bookmark the homepage instead of the desired page.

- Javascript is needed. To run AJAX based website, your browser need to have javascript enabled.

The Solutions:
AJAX is not a perfect technology, but some of the limitations can be overcame with some simple solutions. I found this very userful plugin called jquery.history.js. It solves Browser Back Button. For the bookmark problem, we can solve it by appending a hash value in the end of the url. For the last one - javascript, we are going to ignore it. It can be done but I want to keep this tutorial simple.
And, of course, you'll need a good web server as well, if you're hunting for a web hosting company, you can click here to read reviews about the best web hosting out there!

Requirements

You will need the following items and environment to run this script:
- Web server with PHP support - XAMPP (mac, win and linux)

- jQuery
- history.js

1. HTML

I will provide two versions of HTML code. The first one is the most basic elements you will need to get it working. And the last one is the one I created with some design
Simplified version:

<ul>
	<li><a href="#page1" rel="ajax">Home</a></li> 
	<li><a href="#page2" rel="ajax">Portfolio</a></li> 
	<li><a href="#page3" rel="ajax">About</a></li>
	<li><a href="#page4" rel="ajax">Contact</a></li>
</ul>

<div class="loading"></div>

<div id="content">
<!-- Ajax Content -->
</div>

2. CSS

This is really really simple, just have to keep the loading and content hidden

#loading {
	background: url(images/load.gif) no-repeat;
	display:none;
}
			
#content {
	font-family:arial;
	font-size:11px;
	display:none;
}

3. Javascript

I have added comments in every single lines of the code.

$(document).ready(function () {
	
	//Check if url hash value exists (for bookmark)
	$.history.init(pageload);	
	    
	//highlight the selected link
	$('a[href=' + document.location.hash + ']').addClass('selected');
	
	//Seearch for link with REL set to ajax
	$('a[rel=ajax]').click(function () {
		
		//grab the full url
		var hash = this.href;
		
		//remove the # value
		hash = hash.replace(/^.*#/, '');
		
		//for back button
	 	$.history.load(hash);	
	 	
	 	//clear the selected class and add the class class to the selected link
	 	$('a[rel=ajax]').removeClass('selected');
	 	$(this).addClass('selected');
	 	
	 	//hide the content and show the progress bar
	 	$('#content').hide();
	 	$('#loading').show();
	 	
	 	//run the ajax
		getPage();
	
		//cancel the anchor tag behaviour
		return false;
	});	
});
	

function pageload(hash) {
	//if hash value exists, run the ajax
	if (hash) getPage();    
}
		
function getPage() {
	
	//generate the parameter for the php script
	var data = 'page=' + document.location.hash.replace(/^.*#/, '');
	$.ajax({
		url: "loader.php",	
		type: "GET",		
		data: data,		
		cache: false,
		success: function (html) {	
		
			//hide the progress bar
			$('#loading').hide();	
			
			//add the content retrieved from ajax and put it in the #content div
			$('#content').html(html);
			
			//display the body with fadeIn transition
			$('#content').fadeIn('slow');		
		}		
	});
}

4. PHP

We will not go further on PHP code, this time, I'm using a basic switch to grab the content. The content for the page is being assigned to a variable called "page". And the last line, output the content.

To debug the php script, you can access it by passing data into it, for example:

http://www.someurl.com/loader.php?page=page1

It should display the content for page1. If you know about php and database, you can store the content in the database and retrieve it. Make a simple form to edit the content and BANG... you got yourself a customized content management system.

//Get the page parameter from the url
switch($_GET['page'])  {
	case 'page1' : $page = 'Page 1'; 
					break;
	case 'page2' : $page = 'Page 2'; 
					break;
	case 'page3' : $page = 'Page 3'; 
					break;
	case 'page4' : $page = 'Page 4'; 
					break;
}
echo $page;

That's it. Make sure you check out the demo and download the source code and play with it. If you have created your own, feel free to drop your link in the comment section to show off!



Free Trial ASP.NET 4.5.1 Hosting :: ASPHostPortal.com Proudly Launches ASP.NET 4.5.1 Free Trial Hosting

clock October 28, 2013 06:26 by author Ben

ASP web hosting specialist ASPHostPortal.com announced this week that it has launched a hosting package with support for Microsoft’s ASP.NET 4.5.1.
The company, which says it specializes in hosting for projects based on Windows, Microsoft SQL Server, ASP.NET, along with various other Microsoft products, launched the service this week, just a few month after the release candidate for ASP.NET 4.5.1 was issued by Microsoft.

Specialization in a certain development technology is one of the more common ways for a hosting provider to distinguish itself in a very commoditized market. ASPHostPortal.com has obviously intentionally narrowed its market to developers using Microsoft technologies.

One of the keys to focusing on a market based around a certain technology is quickly instituting support and expertise around new and emerging elements of that technology
The latest update to Microsoft’s popular .NET technology, ASP.NET 4.5.1. Here are some new features of ASP.NET 4.5.1:

  1. CLR Improvements
  2. multi-core JIT improvements
  3. Async-aware debugging
  4. Managed return value inspection
  5. ADO.NET idle connection resiliency
  6. ASP.NET app suspension
  7. On-demand large object heap compaction
  8. Better discoverability of Microsoft .NET NuGet packages
  9. Supporting large scale deployment of .NET NuGet packages


According to ASPHostPortal.com, its ASP.NET 4.5.1 offerings are distinguished by their low cost, with many of the hosting services supporting the technology being of the more expensive variety. ASPHostPortal.com’s offerings 7 Day Free Trial Hosting to all new customers.

“We pride ourselves on offering the most up to date Microsoft services. We're pleased to launch this product today on our hosting environment” said Dean Thomas, Manager at ASPHostPortal.com. “We have always had a great appreciation for the products that Microsoft offers. With the launched of ASP.NET4.5.1 hosting services, we hope that developers and our existing clients can try this new features.Now, you don’t need to spend a lot of money to get ASP.NET 4.5.1 hosting.”

For more information about new ASP.NET 4.5.1, please visit http://www.asphostportal.com.

About ASPHostPortal.com:

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



ASP.NET 4.5 Free Trial Hosting - ASPHostPortal.com :: AJAX Control ToolKit DragPanel Tutorial ASP.NET C#

clock October 24, 2013 10:25 by author Ben

Ajax is Asynchronous JavaScript And Xml. Ajax is a group of interrelated web development techniques used on the client-side to create asynchronous web applications. With Ajax, web applications can send the data to, and retrieve the data from, a server asynchronously (in the background) without interfering with the display and behavior of the existing page.


Here i am describing how to use the Ajax Control Toolkit in our webpage.

1. Download from Ajax Ajax Control Toolkit site.

2. Extract the downloaded zip file.

3. Add Ajax refrence to you project through the menu bar click on the website and select add reffrence.

4. Go to the Browse tab and select the Ajax dll file and click ok.

5. Now open your webpage and add script manager roomates is present on you in the category of the toolbox and ajax extension.

6. After that open the Ajax Control Toolkit your category and add any webpage with Ajax control, and set its properties ajax control.


The extender DragPanel Easily Allows users to add "draggability" to their controls. The DragPanel targets any ASP.NET Panel and takes an additional parameter that signifies the control to use as the "drag handle". Once initialized, the user can freely drag the panel around the web page using the drag handle.

First add or open a new WebForm to this project and name it DragPanel.aspx

Next we will add a ToolScriptManager.

Now we can drag a PanelControl to the webform, we added some CSS styling to it, we kept it fairly simple, and we also added some text inside the panel.
Here is copy -paste this code on your workspace :



And now you can compile the program and see the result. Literally this DragPanel Control Extender is so easy to use that you will be tempted to use it all the time with all the panels. We hope you understood the AJAX Tutorial posted Today.



ASP.NET MVC 4 Hosting :: How to Make a CheckBoxList in ASP.NET MVC 4

clock October 22, 2013 08:30 by author Mike


This article will show you how to create check box list in ASP.NET MVC. Consider that we have a list consist of three properly Name, ID and IsSelected and we have to show a checkboxlist using this list. First create a model with these properties, consider a category model with three properties and a static method which will return list of model as below. 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
 
namespace Sample.Models
{
    public class Category
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public bool IsSelected{ get; set; }
 
        public static List<Category> getCategory()
        {
            List<Category> category = new List<Category>()
            {
                new Category() { ID =1, Name="Cat1",  IsSelected = true },
                new Category() { ID =2, Name="Cat2",  IsSelected = false },
                new Category() { ID =3, Name="Cat3",  IsSelected = true },
                new Category() { ID =4, Name="Cat4",  IsSelected = false },
                new Category() { ID =5, Name="Cat5",  IsSelected = true },
                new Category() { ID =6, Name="Cat6",  IsSelected = false },
                new Category() { ID =7, Name="Cat7",  IsSelected = true },
                new Category() { ID =8, Name="Cat8",  IsSelected = false },
            };
            return category;
        }
    }

 

}

Add a controller where a method will return a list of model to view. We have ProductCategoryController and index method which return list of model to view as below.

namespace Sample.Controllers
{
    public class ProductCategoryController : Controller
    {
        public ActionResult Index()
        {
            List<Category> model = new List<Category>();
            model = Category.getCategory();
            return View(model);
        }
    }

 

}

Add view to this controller method. In view we have model as list of category. Now to create check box list iterate through each item of model and create checkbox list as below.

@model List<Sample.Models.Category>
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Category</h2>
@using (Html.BeginForm("Index", "ProductCategory", FormMethod.Post))
{
    for (int i = 0; i < Model.Count; i++)
    {
        @Html.CheckBoxFor(m => m[i].IsSelected)
        @Html.Label(Model[i].Name);
                                           
        @Html.HiddenFor(m => m[i].Name)
        @Html.HiddenFor(m => m[i].ID)
        <br />
    }
<div>  <input type="submit" value="Go!" /></div>

}

Now, it is very Interesting thing, when you create @Html.CheckBox it will create automatically a hiddenfield for this checkbox, which will use to maintain checkbox status checked or unchecked, when this list get post to model and to get complete list at controller in post method, you have to add two more hidden field for name and ID (two other properties of list) as above.

Here is post method:

[HttpPost]
public ActionResult Index(List<Category> model)
{
    // do operation on list   

 

    return RedirectToAction("Index");


ASP.NET 4.5 Hosting - ASPHostPortal.com :: 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: 

[WebMethod]
public string MyTestAsynchronousMethod(string strName, int
waitTime)
{
  System.Threading.Thread.Sleep(waitTime);
  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)
        {
            objSW.Reset();
            objSW.Start();
            MyProxy.MyAsync objProxy = new MyProxy.MyAsync();
            objProxy.MyTestAsynchronousMethodCompleted += 
              new MyProxy.MyTestAsynchronousMethodCompletedEventHandler(
              objProxy_MyTestAsynchronousMethodCompleted);
            objProxy.MyTestAsynchronousMethodAsync(txtName.Text, 
              Convert.ToInt32(txtWaitTime.Text));
            DoSomeLongJob();
            lblExecTime.Text = "Total Execution Time :" + 
              objSW.ElapsedMilliseconds.ToString() + " Milliseconds";
        }
        void objProxy_MyTestAsynchronousMethodCompleted(object sender, 
             MyProxy.MyTestAsynchronousMethodCompletedEventArgs e)
        {
            lblResult.Text = e.Result;
        }
        private void DoSomeLongJob()
        {
            System.Threading.Thread.Sleep(5000);
        }
    }
} 


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();
right?

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 - ASPHostPortal.com :: ASPHostPortal.com Proudly Announces Free Trial Windows ASP.NET Hosting

clock October 3, 2013 10:11 by author Ben

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

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

About ASPHostPortal.com:

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



ASP.NET Hosting :: How To Protecting Your .NET Application

clock October 1, 2013 11:53 by author Ben

This article demonstrates how to use Dotfuscator which is shipped freely with Visual Studio 2010 to protect. If you are using this tool for the first time, you will be presented with a License agreement. After accepting the license agreement, you can also register this product to get access to free updates and online support.


On the Dotfuscator UI, right click on the project and click ‘Add Assemblies’ and add an assembly of the project you have created

Note: If you observe, options like Control Flow, String Encryption, Removal, Linking and PreMark are grayed out. That is because they are available in the Professional edition. The Instrumentation option is available but you have to manually enable it.
Once the assembly is selected, hit ‘Ctrl + B’ or go to Build > Build Project
Click on the Results tab and expand the root tree and the sub-trees. The blue diamond shaped icons indicates that they are renamed methods and field



Once the obfuscation process is completed, you can examine the obfuscated assembly using ILDASM. ILDASM is a disassembler utility which comes with the .NET Framework SDK and allows you to decompile .NET assemblies into IL Assembly Language statements. To start ILDASM, go to Visual Studio Command Prompt and type ildasm. Then select the assembly to browse. Here’s a comparison of the same assembly, before obfuscation and after obfuscation



Observe how the method and property names are obfuscated. The obfuscated version makes it difficult to understand what a method or property is doing. You can even open a method to view the IL code. Here’s a comparison of the IL before and after the obfuscation:

As you can observe, Dotfuscator renamed the methods and properties and made it difficult to find out the purpose of each method using a disassembler. You can also explore the different Configuration Options to control the renaming of members or to exclude members you do not want to obfuscate. 
I hope this article was useful and I thank you for viewing it.


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)

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

Tag cloud

Sign in