Cheap and Reliable Hosting :: TIPS for Ajax Developers in ASP.NET MVC

IHostAzure.com | Cheap and reliable ASP.NET MVC hosting. This is another quick blog post for the ASP.NET developers, who’re using ajax (or are going to use the ajax in their applications for async calls for the data to the server), and might be getting confused in the View-part of the MVC pattern. This blog post, would try to tip them up with a simple method of creating ajax functionality in their applications, and how to get the confusion about View-part clear. The background to this post is a question, that arose, of how to use the ajax to get the data in ASP.NET MVC framework. Although that was a simple task, but I know new developers get into trouble in making the logic, that is why I am writing this blog post, to explain the core-concept of the behaviour.

Getting hands dirty in some ASP.NET code

First stage would be to write the back-end code for our application, which is the ASP.NET MVC application. Wait, the first thing I want to elaborate here is that ajax requests don’t usually require you to send entire HTML markup, to be rendered. Usually, ajax requests are used to download just a few details about the user, such as their name, their company name, or a little message such as success message for the process user has started. That is why, sending entire HTML markup would take a lot of time, and network size, by sending entire XML tree as HTML markup.

asp.net2.jpgThat is why, I am going to not-create any View in this project. But I am going to work with just a single Controller. That controller would be used to perform all of the actions, and after the controller has been made, I am going to use the Route mechanism to allow custom URLs in  application; which do not map to our actual HTML files on the application set up. Don’t worry, as the application would build up, the concept of this paragraph would start to get some gravity and you will understand it how did I do and what you would do in order to create your own Ajax running ASP.NET MVC application.

First of all, let us create a Controller. To create a controller, you can get some help from Visual Studio, click on the Controllers folder and Add Controller to it. Name it, what so ever you want to. I named it as AjaxController; to specify that it would control all of the ajax requests over HTTP protocol. Once that has been done, you can create your own action methods that would response to your own personal functions. I didn’t bother creating any complex task, instead I just simply created a function, named it as “CustomAction”. It would be used as the URL to our ajax handling web page.

Inside that page, you would write the following code, to handle it and provide the result to it. Like simple C# application, the functions can have any return data type and thus, in ASP.NET MVC application we can, instead of a View, return a string (or any other data type object) that would be sent down to the client as the response to his ajax request. It would be much simpler, and much shorter in structure.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace AjaxRequests_in_ASPNET_MVC.Controllers
{
   public class AjaxController : Controller
   {
      // GET: Ajax
      public string Index()
      {
         return "Not allowed";
      }

      // Our custom action, URL would be /ajax/customaction
      public string CustomAction()
      {
         // We're going to return a string, not a view.
         return "Hello world, using Ajax in ASP.NET MVC application.";
      }
   }
}

The above code would return a string, that can be then used as a response and rendered into the HTML or done what-so-ever with it.

Now let us change the routes to actually let the application run without having to use a web page that is a View inside the Ajax folder in our Views folder. Open the App_Start folder, and inside there open the RouteConfig file, and inside it. Write this new route.MapPath() function

// Create a new route, set the controller to "Ajax" and the remaining would be the Action
// Note that there are no Views in the Views folder to map to this location.
routes.MapRoute(
   name: "AjaxController",
   url: "Ajax/{action}",
   defaults: new {controller = "Ajax"}
);

Now this code would create a routing scheme in your application, and is able to let your application run without actually having to have a specific file at that location to run and handle the ajax request. In the above code, I am using the URLs of the type “/ajax/customajax“, in this URL ajax is a constant string value, used as a path, and then the customajax would be the action of the controller. When this URL would be called, ASP.NET would execute the CustomAjax action of the controller, and would return the string result inside the function.

TIPS for Ajax Developers in ASP.NET MVC

Performing the ajax code

The ajax code for this project is simple jQuery code to create an async request to the server, to download some more data. But before I share the code for the ajax request, I would like you to make a few changes in the _Layout.cshtml file of your project. The change is to include the jQuery library in the project, so that in the web page you can use the jQuery (because we will be using that layout). Add this line of code to your HTML markup’s <head> element.

<script src="~/Scripts/jquery-1.10.2.js"></script>

Now that the jQuery has been added to your HTML DOM, you can use this library in other pages which has this page set as their layouts, to make use of the jQuery syntax and other objects. I will be using the ajax.

The following code depicts the code used for an example ajax request

$(document).ready(function () {
   $.ajax({
      // The URL
      url: "ajax/customaction",
      // If the request was successfull; which will be, if it is not successfull check for errors
      success: function (data) {
         // Alert the data; it would be "Hello world, using Ajax in ASP.NET MVC application."
        alert(data);
      }
   });
});

Now once this code would run, it would try to make a call to the URL specified, in the above section we discussed how ASP.NET would handle that request using the routings and action methods, and then would return a single string value. It would finally alert the user with the string that would be returned. That would be a single ajax running application, which would return simple plain message to the user without any complex and large sized View.


No #1 Recommended ASP.NET MVC Hosting

ASPHostPortal.com

ASPHostPortal.com  is the leading provider of Windows hosting and affordable ASP.NET  MVC 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.

HostForLIFE.eu

HostForLIFE.eu guarantees 99.9% uptime for their professional ASP.NET MVC 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. 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.

DiscountService.biz

DiscountService.biz is The Best and Cheap ASP.NET MVC 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.


Cheap And Reliable Hosting :: Best UK Windows Hosting 2015

IhostAzure.com| Recommended Best, Cheap and Reliable Windows Hosting. Windows Hosting is perfect for websites, blogs and forums that use ASP.NET and MS SQL, which are only available on the Windows hosting platform.

All of Windows hosting plans come with the popular Plesk control panel for easy website management so whether you are working on your next big project or are looking to move your website. Here i recommended you to choose Best, Cheap and Reliable Windows shared hosting  plan. UKWindowsHostASP.NET is Windows Web Hosting plans are an ideal choice for small to medium websites, blogs and forums for you.  Every plan comes with our 30 day money back guarantee as standard.


Comparison All Windows Shared Hosting Plans

LITESTARTERECONOMYDEVELOPERENTERPRISE
Total Hosted Domains1550UnlimitedUnlimited
Disk Space1 GB1 GB5 GB20 GBUnlimited
Bandwidth10 GB20 GB50 GB100 GBUnlimited
Total SubDomainsUnlimitedUnlimitedUnlimitedUnlimitedUnlimited
DNS Manager
Dedicated Pool
Support UTF-8 Domains
London (UK) Data Center
Pricing StructureLITESTARTERECONOMYDEVELOPERENTERPRISE
36 MONTHS Payment£1.00/month£2.00/month£4.00/month£7.00/month£14.00/month
12 MONTHS Payment £2.00/month£3.00/month£5.50/month £9.00/month£17.00/month
6 MONTHS Payment-£4.00/month £7.00/month£11.00/month£20.00/month
30-days Money Back

Why UKWindowsHostASP.NET?


UKWindowsHostASP.NET – Best 24/7-based Support

  • UKWindowsHostASP.NET is  never fall asleep and  run a service that is operating 24/7 a year. Even everyone is on holiday during Easter or Christmas/New Year, UKWindowsHostASP.NET are always behind in desk serving customers.

UKWindowsHostASP.NET – Excellent Uptime Rate

  • UKWindowsHostASP.NET key strength in delivering the service to you is to maintain server uptime rate. UKWindowsHostASP.NET never ever happy to see your site goes down and truly understand that it will hurt your onlines business. If your service is down, it will certainly become  pain and UKWindowsHostASP.NET will certainly look for the right pill to kill the pain ASAP

UKWindowsHostASP.NET – High Performance and Reliable Server

  • UKWindowsHostASP.NET never ever overload  server with tons of clients. UKWindowsHostASP.NET always load balance  server to make sure they can deliver an excellent service, coupling with the high performance and reliable server.

UKWindowsHostASP.NET – Experts in Windows and ASP.NET Hosting

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

UKWindowsHostASP.NET – Daily Backup Service

  • UKWindowsHostASP.NET realise that your website is very important to your business and hence, UKWindowsHostASP.NET  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.

UKWindowsHostASP.NET – Easy Site Administration

  • With UKWindowsHostASP.NET powerful control panel, you can always administer most of your site features easily without even needing to contact for Support Team. Additionally, you can also install more than 100 FREE applications directly via our Control Panel in 1 minute!

UKWindowsHostASP.NET – Commitment to Outstanding Reliability

  • Reliability, Stability and Performance of our servers remain out 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%

IHostAzure.com :: What’s New In ASP.NET 5

What’s New in ASP.NET 5

ASP.NET 5 is a lean .NET stack for building modern web apps. ASP.NET 5 built it from the ground up to provide an optimized development framework for apps that are either deployed to the cloud or run on-premises. It consists of modular components with minimal overhead, so you retain flexibility while constructing your solutions.

Feature ASP.NET 5

  • New flexible and cross-platform runtime
  • New modular HTTP request pipeline
  • Cloud-ready environment configuration
  • Unified programming model that combines MVC, Web API, and Web Pages
  • Ability to see changes without re-building the project
  • Side-by-side versioning of the .NET Framework
  • Ability to self-host or host on IIS
  • New tools in Visual Studio 2015
  • Open source in GitHub

ASP.NET 5 gives you Greater flexibility by being able to run on three runtimes:

  • Full .NET CLR
    The full .NET CLR is the default runtime for projects in Visual Studio. It provides the entire API set and is your best option for backwards compatibility.
  • Core CLR (cloud-optimized runtime)
    The Core CLR is a lean and completely modular runtime for ASP.NET 5 projects. This CLR has been re-designed into components so you have the flexibility to include only those features that you need in your app. You add the components as NuGet packages. When you are finished, your app is dependent only on required features. By re-factoring the runtime into separate components, we can deliver improvements to the components more quickly because each component is updated on its own schedule. The Core CLR is about 11 megabytes instead of around 200 megabytes for the full .NET CLR. The Core CLR can be deployed with your app and different versions of the Core CLR can run side-by-side (both of these advantages are described in greater detail below).
  • Cross-Platform CLR
    We will release a cross-platform runtime for Linux and Mac OS X. When released, this runtime will enable you to develop and run .NET apps on Mac and Linux devices. We will work closely with the Mono community on this effort. Until its release, you can use the Mono CLR for cross-platform development.

By default, new Visual Studio projects use the full .NET CLR. You can specify the Core CLR in the configuration properties for your project.

Host anywhere

ASP.NET 5 enables you to host your app on IIS or self-host your app in your own process. When you target the Core CLR, you can deploy your app with every dependency bundled within the deployment package. Therefore, your app and its dependencies are completely self-contained and no longer dependent on a system installation of .NET. Any type of device or hosting platform is capable of running the app.

Use different versions of .NET side-by-side

When apps on a server depend on a single, system-wide installation of the .NET Framework, all of the apps have to run the same version of .NET. This situation might have created some anxiety for you when considering whether to upgrade to a new version of the .NET Framework. Perhaps, you wanted some of your apps to use the latest version of .NET but you were unsure whether all of your legacy apps would work appropriately with the new version.

Simplify dependency management

ASP.NET 5 introduces a new, lightweight way to manage dependencies in your projects. You no longer add assembly references to your project instead, you manage dependencies by referencing NuGet packages. You can add NuGet packages through the NuGet Package Manager or you can edit the JSON file (project.json) that lists the NuGet packages and versions used in your project. To add other dependencies, you simply type the name and version number of the NuGet package into your project.json file.

dependenciesIn Visual Studio 2015, IntelliSense assists you with finding the available NuGet packages. The project.json file only includes NuGet packages that you directly added to your project. If you add a NuGet package that is dependent on other packages, those secondary dependencies are loaded but not listed in the project.json file. This approach keeps your project.json file less cluttered and easier to manage. If you remove a NuGet package from project.json, the secondary dependencies are removed too if no other packages need them.

The JSON format makes it easier for you to manage dependencies even when you do not have an available installation of Visual Studio. You can open the project.json file in any type of text editor and make changes, such as updating dependencies for app deployed to the cloud.