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 Core 1.0 Hosting - ASPHostPortal.com :: Easy Steps to Create FileUpload Control With Drag Drop And Progress Bar in ASP.NET

clock July 1, 2016 19:50 by author Dan

This Example explains how to use AjaxFileUpload Control With Drag Drop And Progress Bar Functionality In Asp.Net 2.0 3.5 4.0 C# And VB.NET. May 2012 release of AjaxControlToolkit includes a new AjaxFileUpload Control which supports Multiple File Upload, Progress Bar and Drag And Drop functionality. These new features are supported by Google Chrome version 16+, Firefox 8+ , Safari 5+ and Internet explorer 10 + , IE9 or earlier does not support this feature. AjaxFileUpload Control Example with Drag Drop And Progress Bar.

To start with it, download and put latest AjaxControlToolkit.dll in Bin folder of application, Place ToolkitScriptManager and AjaxFileUpload on the page.

HTML SOURCE

<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"/>


<asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server"

                    OnUploadComplete="UploadComplete"

                    ThrobberID="loader"/>


<asp:Image ID="loader" runat="server"

           ImageUrl ="~/loading.gif" Style="display:None"/>


ThrobberID is used to display loading image instead of progress bar in unsupported browsers. Type of files uploaded can be restricted by using AllowedFileTypes property with comma separated list such as "zip,doc,pdf".

Write following code in OnUploadComplete event to save the file.

C#

protected void UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
{
 string path = Server.MapPath("~/Uploads/") + e.FileName;
 AjaxFileUpload1.SaveAs(path);
}


VB.NET

protected void UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
 {
string path = Server.MapPath("~/Uploads/") + e.FileName;
 AjaxFileUpload1.SaveAs(path);
}


Build and run the code.

Best ASP.NET Core 1.0 Hosting Recommendation

ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers ASP.NET hosting starts from $1/month only. They also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable ASP.NET Hosting, ASPHostPortal.com should be your best choice.



ASPHostPortal.com Announces WordPress 4.5.3 Hosting Solution

clock June 28, 2016 23:06 by author Dan

ASPHostPortal.com is trusted web hosting provider since 2008. We strongly believe in high quality standards and hence, you’ll always find our services better than every other host in this industry. We understand the value of time and hence our ordering process is very simple. Customers can choose servers from multiple price levels to suit their business model. Today, we offer premium WordPress 4.5.3 hosting with fast speed, and uptime guarantee.

WordPress has grown into what would be called a content management system, or CMS. A CMS is a tool to store all of the information required for your website and present it to your visitors in a professional, organized way. Other content management systems include Joomla and Drupal, but the reality is that WordPress is the easiest to understand, the easiest to work with, and the most easily adaptable.

WordPress makes creating, editing and organising your content simple and, as a result, less time-consuming. That gives you more time to focus on other areas of your business. WordPress also gives you the chance to get a professional design to make your website look great - often free of charge.

The best way to see how WordPress streamlines setting up your website is to try it for yourself. WordPress is easy to install on your web hosting or, if you sign up on the WordPress website, you can explore its features with no set-up required.

ASPHostPortal.com provides Premium WordPress 4.5.3 Hosting plans on high performance servers and high-speed internet connection in the world. Every server is equipped with at least 2x Intel Xeon Quad-Core processors and massive amounts of memory. We are using SSD's for storage, which provides much higher performance in terms of I/O and data transfer speed. The servers are connected to the network using multiple 1Gbps ports (bond network). To learn more about their WordPress 4.5.3 Hosting, please visit http://asphostportal.com/WordPress-Hosting

About ASPHostPortal.com:

ASPHostPortal.com is The Best, Cheap and Recommended ASP.NET & Linux Hosting. ASPHostPortal.com has ability to support the latest Microsoft, ASP.NET, and Linux technology, such as: such as: WebMatrix, Web Deploy, Visual Studio, Latest ASP.NET Version, Latest ASP.NET MVC Version, Silverlight and Visual Studio Light Switch, Latest MySql version, Latest PHPMyAdmin, Support PHP, etc. Their service includes shared hosting, reseller hosting, and Sharepoint hosting, with speciality in ASP.NET, SQL Server, and Linux solutions. Protection, trustworthiness, and performance are at the core of hosting operations to make certain every website and software hosted is so secured and performs at the best possible level.



ASP.NET Hosting - ASPHostPortal.com :: Dependency Injection In ASP.NET Core

clock June 28, 2016 20:19 by author Armend

This article explains the dependency injection feature available out of the box in ASP.NET core (ASP.NET 5). It will also cover some of the basics of dependency injection so that everyone can get the most out this article.

What is dependency Injection

Dependency Injection is the process of “injecting” the “dependency” whenever the dependency is requested by a client, where the dependency may be another service which the client (requester) may have no means of knowing how to create.

As an analogy, imagine a person (client) going to office carrying his lunch cooked by himself. In this scenario, the person has a “dependency” on food. But he had to know how to cook his food. But honestly, not everyone (client) knows to cook, but people do need food (dependency). This is where restaurants play the role of dependency Injection. They can supply food (“inject dependency”) to the people (client) without the person (client) needing to know how to cook.

This is also called as Inversion of control. Since the control for creation of the service has been passed from the requester to another entity which takes care of creating the dependencies needed by a class to perform its tasks. The entity which takes care of creating these requested dependencies and injecting them automatically to the client is known as the DI (dependency Injection) container.

Dependency Injection in ASP.NET Core

Ok, enough said about what dependency injection is. I am sure most of you knew it. If not, this is a great feature to know and a great tool to add to your tool belt! Let us now look at how to implement dependency injection out of the box in ASP.NET core.
ASP.NET core applications can leverage built in framework support for implementing dependency injection. It has support for the following types of lifetimes for configured services (injected dependencies).

  •     Transient – A new instance of the service is created each time it is requested. It can be used for stateless and light weight services.
  •     Scoped – A single instance is created once per request.
  •     Singleton – Created only once the first time they are requested.

Now for some code!

Use case

Implement a UniqueKeyProvider service. For demonstrating the lifetimes, we will create three differently named interfaces (one for each type of lifetime) for UniqueKeyprovider, all inheriting from the same parent interface having a single property, UniqueKey.
Also, to further illustrate the scoped and singleton lifetime, we will create another service, SomeService, which will have a dependency on all the three different UniqueKeyProvider services (the three different lifetime services).

1. Service Interface definition

Please note the three differently named interfaces, one for demonstrating each type of lifetime. 

namespace DependencyInjectionASPNetCore.Services 
    { 
        public interface IUniqueKeyProvider 
        { 
            Guid UniqueKey 
            { 
                get; 
                set; 
            } 
        } 
        public interface ITransientUniqueKeyProvider: IUniqueKeyProvider 
        {} 
        public interface IScopedUniqueKeyProvider: IUniqueKeyProvider 
        {} 
        public interface ISingletonUniqueKeyProvider: IUniqueKeyProvider 
        {} 
    } 

2. Service Class definition

    namespace DependencyInjectionASPNetCore.Services 
    { 
        public class UniqueKeyProvider: ITransientUniqueKeyProvider, 
        ISingletonUniqueKeyProvider, 
        IScopedUniqueKeyProvider 
        { 
            public Guid UniqueKey 
            { 
                get; 
                set; 
            } 
            public UniqueKeyProvider(Guid uniqueKey) 
            { 
                UniqueKey = uniqueKey; 
            } 
        } 
    } 

3. Registering the services in the startup.cs

Now register your services in the startup.cs file. This is the step where you are actually configuring your dependency injection container. You are basically instructing your dependency injection container that if the user requests for the service, ITransientUniqueKeyProvider, then please provide with a transient scoped instance of UniqueKeyProviderclass and similarly for the other services.
You need to register your services in the ConfigureServices method in the startup.cs file. Please refer to the code below for registration,

   

    services.AddTransient<ITransientUniqueKeyProvider>(provider =>newUniqueKeyProvider(Guid.NewGuid())); 
    services.AddScoped<IScopedUniqueKeyProvider>(provider =>newUniqueKeyProvider(Guid.NewGuid())); 
    services.AddSingleton<ISingletonUniqueKeyProvider>(provider =>newUniqueKeyProvider(Guid.NewGuid())); 
    services.AddTransient<ISomeService, SomeService>();
 

Note that I am also registering another service, ISomeServicewhich I am just using for demo purposes for showing the nature of transient and singleton lifetime. Also note that SomeService implementation requires dependency on the three Unique Key providers, which will be injected through dependency injection.Implementation of ISomeservice provided below,

4. IsomeService and Someservice Implementation

    public class ISomeService 
    { 
        ITransientUniqueKeyProvider TransientUniquekeyProvider 
        { 
            get; 
            set; 
        } 
        IScopedUniqueKeyProvider ScopedUniquekeyProvider 
        { 
            get; 
            set; 
        } 
        ISingletonUniqueKeyProvider SingletonUniquekeyProvider 
        { 
            get; 
            set; 
        } 
    } 
    public class SomeService: ISomeService 
    { 
        public ITransientUniqueKeyProvider TransientUniquekeyProvider 
        { 
            get; 
            set; 
        } 
        public IScopedUniqueKeyProvider ScopedUniquekeyProvider 
        { 
            get; 
            set; 
        } 
        public ISingletonUniqueKeyProvider SingletonUniquekeyProvider 
        { 
            get; 
            set; 
        } 
        public SomeService(ITransientUniqueKeyProvider transientprovider, 
            IScopedUniqueKeyProvider scopedprovider, 
            ISingletonUniqueKeyProvider singletonprovider) 
        { 
            TransientUniquekeyProvider = transientprovider; 
            ScopedUniquekeyProvider = scopedprovider; 
            SingletonUniquekeyProvider = singletonprovider; 
        } 
    } 

Now it is time to wrap it all up and test it through a controller. I am using the Home controller’s Index action. Please refer to the below code from the controller and view.

5. Home Controller

    public class HomeController: Controller 
    {  
        private ITransientUniqueKeyProvider _transientUniquekeyProvider; 
        private IScopedUniqueKeyProvider _scopedUniquekeyProvider; 
        private ISingletonUniqueKeyProvider _singletonUniquekeyProvider; 
        private ISomeService _someserviceProvider; 
        public HomeController(ITransientUniqueKeyProvider transientprovider, 
            IScopedUniqueKeyProvider scopedprovider, 
            ISingletonUniqueKeyProvider singletonprovider, ISomeService someserviceprovider) 
        { 
            _transientUniquekeyProvider = transientprovider; 
            _scopedUniquekeyProvider = scopedprovider; 
            _singletonUniquekeyProvider = singletonprovider; 
            _someserviceProvider = someserviceprovider; 
        } 
        public IActionResult Index() 
        { 
            ViewBag.transientID = _transientUniquekeyProvider.UniqueKey; 
            ViewBag.scopedID = _scopedUniquekeyProvider.UniqueKey; 
            ViewBag.singletonID = _singletonUniquekeyProvider.UniqueKey; 
            ViewBag.someServiceProvider = _someserviceProvider; 
            return View(); 
        } 
    } 

Note the constructor which takes in the dependencies. So when the request comes to this page, the framework notes that it needs an implementation for these services. It checks the DI container and finds the registration, and based on that the valid instance is passed to the constructor. The same happens in case of the ISomeService dependency which the controller’s constructor needs.

6. Index View

In the view file, we are just displaying the values that we set in the view bag. Results provided in the next section.

<div style="margin-top:35px"> 
lt;pstyle="font-weight:bold;text-decoration:underline"> 
These are the values that were injected into the home controller 
</p> 
<p> 
    Transient value of Guid: @ViewBag.transientID 
</p> 
<p> 
    Scoped value of Guid: @ViewBag.scopedID 
</p> 
<p> 
    Singleton value of Guid: @ViewBag.singletonID 
</p> 
</div> 
 
<div> 
    <p style="font-weight:bold;text-decoration:underline"> 
 
        These are the values that were injected into Someservice Implementation 
        </p> 
        <p> 
            Transient value of Guid: @ViewBag.someServiceProvider.TransientUniquekeyProvider.UniqueKey 
        </p> 
        <p> 
            Scoped value of Guid: @ViewBag.someServiceProvider.ScopedUniquekeyProvider.UniqueKey 
        </p> 
        <p> 
            Singleton value of Guid: @ViewBag.someServiceProvider.SingletonUniquekeyProvider.UniqueKey 
        </p> 
</div>

I really hope it was useful and fun. Happy coding!

 



ASP.NET Core 1.0 Hosting - ASPHostPortal.com :: How to integrate those fancy modal image preview in ASP.NET

clock June 27, 2016 20:51 by author Dan

Today, in this post I will quickly show you " How to integrate those fancy modal image preview in ASP.NET ".
Magic library for this functionality is mighty FancyBox the "tool that offers a nice and elegant way to add zooming functionality for images, html content and multi-media on your webpages. It is built at the top of the popular JavaScript framework jQuery and is both easy to implement and a snap to customize."

Let's see how things are working....

  1. We create web site project inside our VS 2012.
  2. Include into project jQuery in this sample I use latest version 1.7.2.
  3. Also we need to include FancyBox. (It would be very strange to not include it in this sample)

So, our project look's like:

Here you can see our included files inside project, also you can see our test page html and jQuery code.
Most important thing here is that you use class="fancybox" as image control css class.

jQuery code is very very simple as you can see here:

       $(document).ready(function () {
            $(".fancybox").fancybox();
        });


There are more cases in how to use fancybox that you can check at FancyBox.

Effect that we managed to create looks like this:

When we click on image we get this.

So, long, folks!

Best ASP.NET Core 1.0 Hosting Recommendation

ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers ASP.NET hosting starts from $1/month only. They also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable ASP.NET Hosting, ASPHostPortal.com should be your best choice.



ASP.NET Hosting - ASPHostPortal.com :: ASP.NET Seo Tips

clock June 21, 2016 20:41 by author Armend

When running an online business, majority of our focus is on the design, architecture of the website and how efficiently it displays our product. These are not the only things that are required to target the infinite Internet audience. One need to keep in mind that the main source of audience come from search engines such as Google, Yahoo, Bing and others. So the application or the website should be able to follow simple rules and handle your business efficiently. ASP.NET application is spreading rapidly and if you are using an ASP.NET website few simple guidelines has to be considered. The below mentioned points need to be implemented:

 

Page Titles

Page titles between tags is one important thing that many fail to practice in SEO. When a search is made in Google, these titles show up as links in the result. So that explains its importance. The common mistake among website owners is giving the same title for all pages. Page titles drive traffic to your site, hence it is important to have a proper title to attract visitors. Adding titles is not as hard as you imagine. If you have a product catalog use your product name as title. You can also choose to give a different title that is related to your product.

Meaningful URL

URLs that are long with query parameters do not look neat and it is difficult for the visitor to remember. Instead use formatted URLs for your static pages. URL which has a meaning explains the content in your website. Although experts agree with using an URL that has query parameters, it is better to have a meaningful URL. Components like UrlRewritingNet can be used for this purpose. Mapping support in URL is offered by IIS7 which has plenty of features.

Structure of the Content

Content without a structure is not possible.  You will have titles, headings, sub headings, paragraphs and others. How would you emphasize some quotes or important points in your content? If you follow the below mentioned steps, the structure of your content will be semantically correct.

  • Divide long stories or parts using headings. Short paragraphs make more sense to the readers. Use tags to bring beauty to your content.
  • If you want to emphasize an important point or quote, place them between tags.

Visitors can create structured content if you use FCKEditor and the like. Integrating these to your website is not complex.

Clean the Source Code

Don’t panic, it is advisable to clean up the source code and minimize the number of codes. The following simple steps will assist you in cleaning the source code: You can use

  •     External stylesheets and not inline CSS
  •     -js files instead of inline JavaScript
  •     HTML comments is not encouraged
  •     Avoid massive line breaking
  •     Avoid using viewstate when not required

The relation between the content and the code (JavaScript, HTML, CSS) determines the ranking of your website. Smaller source codes help build a strong relation.

Crawlable Site

Do not use

  • Silver or flash light for menus or to highlight information
  • Menus based on JavaScript
  • Menus based on buttons
  • Intro-pages

Do use

  • Simple tags wherever possible
  • Sitemap
  • “Alt” for images
  • RSS

Test the Site

What happens to the requests that are sent when the site is slow? Sometimes requests are sent by robots and if they are unable to connect to your site continuously, they drop the site from their index. Enable your site to respond fast to requests even during peak hours. Moreover, visitors don’t like to visit slow sites. Use the various tools available and conduct the stress test for your site. Perform this and locate all the weak parts of the site. Fix them so that your site gets indexed.

Test the AJAX site

Spiders can only run a few parts of your AJAX website because they don’t run JavaScripts. Spiders can only analyze the data and hence they remain invisible to robots. The AJAX sites do not get indexed which does not help in search engine optimization. To make the site spider friendly, try and keep away from initial content loading into the JavaScript. You can also follow this only for pages that you like to index.  Make it easy for robots so that they can navigate. Try this simple trick to see how your AJAX site will appear to the robots. Disable JavaScript from the browser and visit your AJAX site. You can view the pages which robots will index.

 



ASP.NET Core 1.0 Hosting - ASPHostPortal.com :: Easy Steps to Change CSS programmatically in C# ASP.NET

clock June 20, 2016 21:45 by author Dan

In this example we explain that how to change CSS dynamically from code behind in asp.net using C#. or how to change CSS file programmatically in C# code(back end  code) in asp.net.

Some time we have requirement like if user click on or check Lightweight button then Lightweight CSS is apply to the application for these user only same like if user checked or click on Professional button then Professional look is applied to the application for these user only these totally is dynamic and depend on user requirement.

So how to change or switch CSS file dynamically from code behind in asp.net using C#.

ChangeCSSFileDynamically.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ChangeCSSFileDynamically.aspx.cs"
    Inherits="WebApplication1.ChangeCSSFileDynamically" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Dynamically change (switch) CSS file programmatically from code behind in ASP.Net</title>
    <link id="lnkCSS" runat="server" href="~/CSS/Lightweight.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <asp:Label ID="Label1" runat="server" Text="This is a Label" CssClass="label"></asp:Label>
    <hr />
    <asp:RadioButton ID="chkLightWeight" runat="server" GroupName="CSSTheme" AutoPostBack="true" Text="LightWeight"
        OnCheckedChanged="chkLightWeight_CheckedChanged1" />
    <asp:RadioButton ID="chkProfessional" runat="server" GroupName="CSSTheme" AutoPostBack="true" Text="Professional"
        OnCheckedChanged="chkProfessional_CheckedChanged1" />
    </form>
</body>
</html>

ChangeCSSFileDynamically.aspx.cs:

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

namespace WebApplication1
{
    public partial class ChangeCSSFileDynamically : System.Web.UI.Page
    {

        protected void chkLightWeight_CheckedChanged1(object sender, EventArgs e)
        {
            lnkCSS.Attributes["href"] = "~/CSS/Lightweight.css";
        }

        protected void chkProfessional_CheckedChanged1(object sender, EventArgs e)
        {
            lnkCSS.Attributes["href"] = "~/CSS/Professional.css";
        }
    }
}

Lightweight.css:

body
{
    font-family:Times New Roman;
    font-size:10pt;
}
.label
{
    font-weight:bold;
    color:Purple;
}

Professional.css:

body
{
    font-family:Arial;
    font-size:bold;
}
.label
{
    font-weight:bold;
    color:yellow;
}

Best ASP.NET Core 1.0 Hosting Recommendation

ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers ASP.NET hosting starts from $1/month only. They also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable ASP.NET Hosting, ASPHostPortal.com should be your best choice.



ASP.NET Core 1.0 Hosting - ASPHostPortal.com :: 7 Advantages When Using JQuery in ASP.NET

clock June 17, 2016 22:52 by author Dan

These days there are plenty of options available in case of frameworks as well as programs for the creation of webpages. One program that helps in easy scripting as well as programming is ASP.NET; jQuery gives great benefit to the program. The open source light weight JavaScript library called jQuery is a fantastic option for easy and fast HTML DOM manipulation as well as traversing, client side animations as well as scripting, event handling, etc. It also helps in easy integration of your SharePoint and ASP.Net applications. The combination of both the programs is quite intriguing which helps you create server-side dynamic websites very easily.

You can use both together very easily. Microsoft programs in fact, are bundled with jQuery so that it may be used with ASP.Net. Visual Studio is one such program which acts as the key for the creation of web pages along with coding in several languages through intellisense. In case, there is no integration between the two you simply have to download the recent jQuery library which is easily available from jQuery.com; then copy or unzip the file in the website project's root directory.

Advantages

More functionality with less writing - A huge benefit offered by this is that very less code is needed for performing of several complicated client side operations by virtue of several chaining mechanisms, selector expressions support along with other familiar features that make it easier to conduct complex DOM manipulation. The chaining mechanism helps in code reduction.

Easy, fast and lightweight -
From point of size the library is only 20KB in compressed form which makes it light, as such the execution time is less as well. When using the platform, the sheer simplicity can be easily understood. When compared to the normal JavaScript code, the development time is quite less. There are also no security risks associated; it may be included in the project simply like any JavaScript file.

Different codes than HTML mark ups - Client side scripts can be easily separated from HTML mark ups by virtue of the library. The program's $(document).ready() function enables this function. When the library is being used, the HTML code can be made neat with the combination of any JavaScript code. In fact the code can even be separated into separate file to link it to aspx page.

Cross browser compatibility -
The code is compatible with every browser which prevents any necessity for writing individual client side code meant for various browsers. When using the program to maintain cross browser compatibility, the css properties should be set so that they are compatible accordingly.

Presence of several plug-ins - The internet has several plug-ins freely available for use in the projects. There is a huge directory of plug-ins which accounts for the high jQuery usage which is growing each day. In fact, many of the available plug-ins may be re-used.

Lightweight and easy Ajax application -
A huge advantage of using the library lies in the development of light weight Ajax application with JSON support in ASP.Net. The library helps in prevention of bulky UpdatePanel control meant for Ajax communications.

Use of Content Distribution Network for internet sites - For the sites which are hosted on internet, the using of library hosted by Google CDN becomes easy. Major open source widely used JavaScript libraries are used globally across sites by virtue of the network. This helps in the management of recent updates, bug fixes as well as provision of high speed access for better caching.

Other advantages are easy integration between jQuery and ASP.NET Ajax projects and extension of existing functionality. In fact, the benefits do not simply stop with those mentioned here. When the platform is actually used, then only you will be able to understand a lot more points. There are no security risks associated with the usage which gives yet another benefit to the developers.

You can hire developers from top asp.net application development companies in India who can help you build web applications according to your ideas within allocated budget and time schedules.

Best ASP.NET Core 1.0 Hosting Recommendation

ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers ASP.NET hosting starts from $1/month only. They also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable ASP.NET Hosting, ASPHostPortal.com should be your best choice.



ASP.NET Hosting - ASPHostPortal.com :: How to Publishing an ASP.NET 5 Project to a Local IIS Server

clock June 16, 2016 17:45 by author Armend

In this post we will show you how to publishing an ASP.NET 5 project to a local IIS server. Recently I deployed a new ASP.NET 5 web application to a local IIS server. Though there are several online resources available about deployment, I encountered some problems that were difficult to diagnose and fix. In this post I will talk about the general deployment process and the steps I followed for a successful deployment.

ASP.NET 5 applications are meant to be cross-platform. Included in this cross-platform effort is the development of a new, cross-platform web server, named Kestrel. The Kestrel web server can be activated from the command line and can be used on any operating system.
Of course, ASP.NET 5 applications can still be hosted in IIS. But even in this case, the underlying web server will still be Kestrel. The role of IIS is greatly minimized.
In this post we will be deploying a web application using Kestrel as a web host first. Afterwards, we will be deploying to IIS.

Deployment to Kestrel

Let's say that we have an existing ASP.NET 5 application. We can publish the application from the command line. First, navigate to the root web folder of the application (the folder where the project.json file is in). Then, type in the following command:

dnu publish --runtime active -o ..\publish

What this will do is create a new folder named 'publish' alongside the root web folder. Inside this 'publish' folder , there will be three subfolders: 'approot', 'logs', and 'wwwroot'. The 'approot' folder will contain the source files and packages needed by the application. The 'logs' folder will contain any logs that the application emits. The 'wwwroot' folder will contain javascript, html, css files, etc. as well as the web.config file.
Now we can start the Kestrel web server. First, navigate to the 'approot' folder. There will be a file named web.cmd. Start it by typing 'web' from the command line or double-clicking on it from a windows explorer window.

You might notice that a lot of text appears on the command line as soon as the command is run. This is especially true when there are Entity Framework migrations involved. Among the sea of text, the URL of the localhost web server will be displayed, and will look something like this:

Hosting Environment: Production
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.

Once we find this text, we can just navigate to the appropriate URL using a browser. There we should see the web app up and running.
Congratulations, we have just deployed our ASP.NET 5 web application!
Deployment to IIS
Once we successfully launch the app through Kestrel, we can go for deploying in IIS. We need to do a few things for it to work properly.

  • Use an application pool with No Managed Code as the .NET CLR Version.
  • Create a Login in SQL Server with the login name as IIS APPPOOL\{apppoolname}. This Login should have access to whatever database the web application will use.
  • Create access rights to the 'wwwroot' folder for the user group IIS_IUSRS.

In addition, if we are going to put the application inside IIS Default Web Site and use a virtual directory, we need to modify the Startup.cs to handle this.
The first step is to rename the Configure method to something else, for example Configure1.
Then, we need to create a new Configure method. This would have the same signature as the original Configure method. The implementation would look something like this:

public async void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    app.Map("/virtualdirectoryname", (app1) => this.Configure1(app1, env, loggerFactory));
}

So we see that this new Configure method just calls the Configure1 method, taking into account the virtual directory name.
Once all of these are in place, we can go ahead and deploy to IIS using the usual process. We can add a new application in IIS Default Web Site and use the application pool we created earlier (using No Managed Code). The physical path should point to the 'wwwroot' location. The alias should be the same as the one we put in the Configure method in Startup.cs.
Afterwards, just browse to the website and it should all be good!

Conclusion

Although the concept of deployment stayed the same, the process and tools involved for deploying ASP.NET 5 applications has changed. In this post we took a look at how to deploy to the Kestrel web server, then later to IIS. Though it might seem like a long process, most of the steps should only be performed the first time around. Subsequent deployments should be faster and more straightforward.



ASPHostPortal.com Announces Drupal 8.1.2 Hosting Solution

clock June 14, 2016 23:23 by author Dan

ASPHostPortal.com was established with the goal to provide high quality Drupal hosting services for everyone. They believe that providing high quality services should come at an affordable price. For this reason they have provided exceptional Drupal hosting plans, at the lowest prices, for the best services possible, on fastest nodes ever. Today, they offer Drupal 8.2.1 hosting with very easy installation.

Drupal is an open source CMS that gives its users a large degree of flexibility to modify, share, and distribute content (text, video, data, business services). Still, Drupal is more than a CMS. It is a Software as a Service (SaaS) solution that is perfect for a small business and scalable for any large enterprise.

Unlike many website content management systems that offer narrow frameworks and custom coding, Drupal comes out of the box ready to showcase your brand in an interactive, highly-useable environment. You can design your Drupal web design to match your business needs without many of the restrictions of previous CMS tools.

ASPHostPortal.com is a web hosting provider dedicated to providing high quality Drupal hosting at an affordable price. They care for the clients, ensuring each and every client is more than just satisfied day in and day out. They only use the best hardware, super fast network, covered by 24/7 Support Team. They have 12 world class data centers, located in USA, Europe, Asia and Australia. Each of locations will provide with amazing performance to make Drupal website more powerful. To learn more about their Drupal 8.1.2 Hosting, please visit http://asphostportal.com/Drupal-8-1-2-Hosting

About ASPHostPortal.com:
ASPHostPortal.com is The Best, Cheap and Recommended ASP.NET & Linux Hosting. ASPHostPortal.com has ability to support the latest Microsoft, ASP.NET, and Linux technology, such as: such as: WebMatrix, Web Deploy, Visual Studio, Latest ASP.NET Version, Latest ASP.NET MVC Version, Silverlight and Visual Studio Light Switch, Latest MySql version, Latest PHPMyAdmin, Support PHP, etc. Their service includes shared hosting, reseller hosting, and Sharepoint hosting, with speciality in ASP.NET, SQL Server, and Linux solutions. Protection, trustworthiness, and performance are at the core of hosting operations to make certain every website and software hosted is so secured and performs at the best possible level.



ASP.NET Core 1.0 Hosting - ASPHostPortal.com :: How To Configure your ASP.‚ÄčNET Core 1.0 Application

clock June 14, 2016 20:26 by author Armend

The Web.Config is gone and the AppSettings are gone with ASP.NET Core 1.0. How do we configure our ASP.NET Core Application now? With the Web.Config, also the config transform feature is gone. How do we configure a ASP.NET Core Application for specific deployment environments?

Configuring

Unfortunately a newly started ASP.NET Core Application doesn't include a complete configuration as a sample. This makes the jump-start a little difficult. The new Configuration is quite better than the old one and it would make sense to add some settings by default. Anyway, lets start by creating a new Project.
Open the Startup.cs and take a look at the controller. There's already something like a configuration setup. This is exactly what the newly created application needs to run.

public Startup(IHostingEnvironment env)
{
    // Set up configuration sources.
    var builder = new ConfigurationBuilder()
        .AddJsonFile("appsettings.json")
        .AddEnvironmentVariables();
    if (env.IsDevelopment())
    {
        // This will push telemetry data through Application Insights
        // pipeline faster, allowing you to view results immediately.
        builder.AddApplicationInsightsSettings(developerMode: true);
    }
    Configuration = builder.Build();
}

But in the most cases you need much more configuration. This code creates a ConfigurationBuilder and adds a appsettigns.json and environment variables to the ConfigurationBuilder. In development mode, it also adds ApplicationInsights settings.
If you take a look into the appsettings.json, you'll only find a ApplicationInsights key and some logging specific settings (In case you chose a individual authentication you'll also

see a connection string):
{
  "ApplicationInsights": {
    "InstrumentationKey": ""
  },
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Verbose",
      "System": "Information",
      "Microsoft": "Information"
    }
  }
}

Where do we need to store our custom application settings?
We can use this appsettings.json or any other JSON file to store our settings. Let's use the existing one to add a new section called AppSettings:

{
...
    "AppSettings" : {
        "ApplicationTitle" : "My Application Title",
        "TopItemsOnStart" : 10,
        "ShowEditLink" : true
    }
}

This looks nice, but how do we read this settings?

In the Startup.cs the Configuration is already built and we could use it like this:

var configurationSection = Configuration.GetSection("AppSettings");
var title = configurationSection.Get<string>("ApplicationTitle");
var topItmes = configurationSection.Get<int>("TopItemsOnStart");
var showLink = configurationSection.Get<bool>("ShowEditLink");
We can also provide a default value in case that item doesn't exist or in case it is null
var topItmes = configurationSection.Get<int>("TopItemsOnStart", 15);

To use it everywhere we need to register the IConfigurationRoot to the dependency injection container:

services.AddInstance<IConfigurationRoot>(Configuration);

But this seems not to be a really useful way to provide the application settings to our application. And it looks almost similar as in the previous ASP.NET Versions. But the new configuration is pretty much better. In previous versions we created a settings facade to encapsulate the settings, to not access the configuration directly and to get typed settings.
No we just need to create a simple POCO to provide access to the settings globally inside the application:

public class AppSettings
{
    public string ApplicationTitle { get; set; }
    public int TopItemsOnStart { get; set; }
    public bool ShowEditLink { get; set; }
}

The properties of this class should match the keys in the configuration section. Is this done we are able to map the section to that AppSettings class:

services.Configure<AppSettings>(Configuration.GetSection("AppSettings"));

This fills our AppSettings class with the values from the configuration section. This code also adds the settings to the IoC container and we are now able to use it everywhere in the application by requesting for the IOptions<AppSettings>:

public class HomeController : Controller
{
    private readonly AppSettings _settings
    public HomeController(IOptions<AppSettings> settings)
    {
        _settings = settings.Value;
    }
    public IActionResult Index()
    {
        ViewData["Message"] = _settings.ApplicationTitle;
        return View();
    }

Even directly in the view:

@inject IOptions<AppSettings> AppSettings
@{
    ViewData["Title"] = AppSettings.Value.ApplicationTitle;
}
<h2>@ViewData["Title"].</h2>
<ul>
    @for (var i = 0; i < AppSettings.Value.TopItemsOnStart; i++)
    {
        <li>
            <span>Item no. @i</span><br/>
            @if (AppSettings.Value.ShowEditLink) {
                <a asp-action="Edit" asp-controller="Home"
                   asp-route-id="@i">Edit</a>
            }
        </li>
    }
</ul>

With this approach, you are able to create as many configuration sections as you need and you are able to provide as many settings objects as you need to your application.
What do you think about it? Please let me know and drop a comment.

Environment specific configuration

Now we need to have differnt configurations per deployment environment. Let's assume we have a production, a staging and a development environment where we run our application. All this environments need another configuration, another connections string, mail settings, Azure access keys, whatever...
Let's go back to the Startup.cs to have a look into the constructor. We can use the IHostingEnvironment to load different appsettings.json files per environment. But we can do this in a pretty elegant way:

.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)

We can just load another JSON file with an environment specific name and with optional set to true. Let's say the appsettings.json contain the production and the default

  • settings and the appsettings.Staging.json contains the staging sepcific settings. It we are running in Staging mode, the second settings file will be loaded and the existing settings will be overridden by the new one. We just need to sepcify the settings we want to override.
  • Setting the flag optional to true means, the settings file doesn't need to exist. Whith this approatch you can commit some default setings to the source code repository and the top secret access keys and connections string, could be stored in an appsettings.Development.json, an appsettings.staging.json and an appsettings.Production.json on the buildserver or on the webserver directly.

Conclusion

As you can see, configuration in ASP.NET Core is pretty easy. You just need to know how to do it. Because it is not directly visible in a new project, it is a bit difficult to find the way to start.

 



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