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 Hosting - ASPHostPortal.com :: New Ways To Organize Razor Views in ASP.NET Core

clock May 30, 2016 20:50 by author Armend

New Ways To Organize Razor Views in ASP.NET Core

Currently there are many ways to extend or to organize Razor views in ASP.NET Core. Let us start with the new more complex ways. If your are familiar with previous ASP.NET MVC Frameworks you’ll definitely know most. But not almost all of that “old” stuff is still possible in ASP.NET Core MVC. Some of the listed below is completely new in ASP.NET Core. With this post, we’re going to try to write down all options to organize MVC Views in ASP.NET Core.

 

How To Organize Razor Views in ASP.NET Core

1. ViewComponents

This is one of new way to organize Razor views in ASP.NET Core. Sometimes you need to have something like PartialView, but with some more logic behind. In the past there was a way to use ChildActions to render the results of controller actions into a view. In ASP.NET Core, there is a new way (which I already showed in this post about ViewCmponents) with ViewComponents. This are a kind of mini MVC inside MVC, which means they have an own Controller, with an own single action and a view. This ViewComponents are completely independent from your current view, but also can get values passed in from your view. To render a ViewComponent you need to call it like this:

@Component.Invoke("Top10Articles");

2.  TagHelper

This little helpers are extensions of your view, which are looking like real HTML tags. In ASP.NET Core, you should use this TagHelpers instead of the HtmlHelpers because they are more cleaner and easier to use. Another huge benefit is Dependency Injection, which can’t be used with the HtmlHelpers, because the static context of extension methods. TagHelpers are common classes where we can easily inject services via the constructor. A pretty simple example on how a TagHelper could look like:

[TargetElement("hi")]
public class HelloTagHelper : TagHelper
{
    public override void Process(TagHelperContext context, TagHelperOutput output)
    {
        output.TagName = "p";
        output.Attributes.Add("id", context.UniqueId);
        output.PreContent.SetContent("Hello ");
        output.PostContent.SetContent(string.Format(", time is now: {0}", 
                DateTime.Now.ToString("HH:mm")));
    }
}

This guy defines a HTML Tag called “hi” and renders a p-tag and the contents and the current Time.
Usage:

<hi>armend</hi>

Result:
<p>Hello armend, time is now: 18:55</p>

ASP.NET Core MVC provides many built in TagHelpers to replace the most used HtmlHelpers. E. g. the ActionLink can now replaced with an Anchor TagHelper:

@Html.ActionLink(“About ��, “About”, “Home”)

The new TagHelper to create a link to an action looks like this:

<a asp-controller=”�� asp-action=”��>About me</a>

The result in both cases is a clean a-Tag with the URL to the about page:

<a href=”/Home/��>About me</a>

As you can see the TagHelpers feel more than HTML and they are easier to use and more readable inside the Views.

3. Dependency Injection

This is the biggest improvement to organize Razor views in ASP.NET Core. Yes, you are able to use DI in your View. Does this really make sense? Doesn’t it mess up my view and doesn’t it completely break with the MVC pattern? (Questions like this are currently asked on StackOverflow and reddit). We think, no. Sure, you need be careful and you should only use it, if it is really needed. This could be a valid scenario: If you create a form to edit a user profile, where the user can add its job position, the country where he lives, his city, and so on. We would prefer not to pass the job positions, the country and the cities from the action to the view. We would prefer only to pass the user profile itself and We only want to handle the user profile in the action. This is why it is pretty useful in this case to inject the services which gives me this look-up data. The action and the ViewModel keeps clean and easy to maintain.
Just register your specific service in the method ConfigureServices in the Startup.cs and use one line of code to inject it into your view:

@inject DiViews.Services.ICountryService CountryService;

Now you are able to use the ContryService in your View to fill a SelectBox with list of countries.

4. Global View Configuration

Last but not least, there is a separate razor file you can use to configure some things globally. Use the _ViewImports.cshtml to configure usings, dependency injections and many more which should be used in all Views.

Conclusion

There are many new ways to extend and organize Razor views in ASP.NET Core. But you are free to decide which feature you want to use to get your problems solved. While there are many programming languages out there for a web developer to choose from, one of the most successful programming language till this date is ASP.NET. It has matured over the years with the latest version, ASP.NET Core, having a number of new features and enhancements. You may already have heard that ASP.NET hosting is offered by several web hosting providers. However, choosing the best cheap ASP.NET hosting isn’t an easy task.

 



ASP.NET Hosting - ASPHostPortal.com :: How To Create a Help Desk Web Application using ASP.NET

clock May 24, 2016 20:04 by author Armend

Suppose you work for a small to midsize company that employs 50-100 workers. The Help Desk -- a subsidiary of the Information Services Division -- is in charge of trouble tickets regarding general PC issues such as email, viruses, network issues, etc. Initially, the Help Desk team stored this information in Excel spreadsheets, but as the company has grown, managing these spreadsheets has become tedious and time consuming.

The Help Desk has asked you to devise a more efficient solution that could be developed internally, saving the company money. As you start to think about it, the following requirements are apparent: fields for the submitter's first and last name, as well as their email address. You'll also need combo boxes for indicating ticket severity (low, medium, high), department, status (new, open, resolved), employee working on the issue, as well as an area for comments. Of all the solutions available, creating an internal help desk Web application with ASP.NET is relatively simple.

In the following article, we'll see how to implement these features in an ASP.NET help desk Web application using a database-driven approach,
Creating the JavaScript File
Because creating the JavaScript file is the easiest of the work left, we'll do this next. From the Solution Explorer, follow these steps:

Creating the Help Desk Class

Now that we have our data coming in, we need to be able to record a help desk ticket submission. We need to create an event handler in a class to handle it. Let's first create a help desk class by doing the following:

  •     Right click the project solution.
  •     Choose Add>New Item.
  •     In the Add New Item window, select Class.cs.
  •     In the name text field, type "HelpDesk" and then click Add.

Double click HelpDesk.cs from the Solution Explorer, which will show the empty class as shown below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace HelpDesk
{
    public class HelpDesk
    {
    }
}

We need to import three libraries as shown below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
namespace HelpDesk
{
    public class HelpDesk
    {
    }
}

The first library (System.Data) allows us to work with stored procedures in ADO.NET, the second (System.Configuration) allows us to reference a connection key from configuration file and the last (System.Data.SqlClient) one allows us to connect to SQL Server.

 

 



ASPHostPortal.com Announces DotNetNuke 8.0.2 Hosting Solution

clock May 18, 2016 00:10 by author Dan

ASPHostPortal.com was established with the goal to provide high quality hosting services for everyone. We believe that providing high quality services should come at an affordable price. For this reason we have provided exceptional plans, at the lowest prices, for the best services possible, on fastest nodes ever. Today, we offer DotNetNuke 8.0.2 hosting with cheap price and good service.

DotNetNuke is an expandable Web Application Platform. Third party applications and services can be deployed as DotNetNuke Modules. Modules are pieces of code that each present some functionality to the user, like a personnel contacts list, events calendar, or a list of announcements. Installing a module is a simple administrative task and it does not require programming. Once installed, third party modules are visually integrated with the rest of the site because they use the graphic styles of the current Skin.

Modules are completely integrated with the site security and internationalization settings. Modules can be easily added, edited, deleted, restored, moved around on a page, or transferred to other pages. DotNetNuke is fully localized. Built-in multi-language localization features allow administrators worldwide to easily use and adapt DotNetNuke software for their own use. Over 50 Language Packs are available through the DotNetNuke community.

ASPHostPortal.com provides Premium DotNetNuke 8.0.2 hosting plan 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 our DotNetNuke 8.0.2 Hosting, please visit http://asphostportal.com/DotNetNuke-8-0-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 Hosting - ASPHostPortal.com :: How to set up Output Caching in ASP.NET

clock May 17, 2016 19:52 by author Armend

How to set up Output Caching in ASP.NET

Hi today we are talking about Output Caching in ASP.NET , so i hope you will enjoy and get something from it .

What is Output Caching ?

Output caching has enabled developers to store the generated output of pages, controls, and HTTP responses in memory. On subsequent Web requests, ASP.NET can serve content more quickly by retrieving the generated output from memory instead of regenerating the output from scratch.

Limitation :

Generated content always has to be stored in memory, and on servers that are experiencing heavy traffic, the memory consumed by output caching can compete with memory demands from other portions of a Web application.

Role in ASP.NET  5 :

ASP.NET 5 adds an extensibility point to output caching that enables you to configure one or more custom output-cache providers. Output-cache providers can use any storage mechanism to persist HTML content. This makes it possible to create custom output-cache providers for diverse persistence mechanisms, which can include local or remote disks, cloud storage, and distributed cache engines.

You create a custom output-cache provider as a class that derives from the new System.Web.Caching.OutputCacheProvider type. You can then configure the provider in the Web.config file by using the new providers subsection of the outputCache element, as shown in the following example:

&lt;caching&gt;
&lt;outputCache defaultProvider="AspNetInternalProvider"&gt;
&lt;providers&gt;
&lt;add name="DiskCache"
type="Test.OutputCacheEx.DiskOutputCacheProvider, DiskCacheProvider"/&gt;
&lt;/providers&gt;
&lt;/outputCache&gt;
&lt;/caching&gt;


By default in ASP.NET 4, all HTTP responses, rendered pages, and controls use the in-memory output cache.You can change the default output-cache provider used for a Web application by specifying a different provider name for defaultProvider.

&lt;%@ OutputCache Duration="60" VaryByParam="None" providerName="DiskCache" %&gt;

 

Specifying a different output cache provider for an HTTP request requires a little more work. Instead of declaratively specifying the provider, you override the new GetOuputCacheProviderName method in the Global.asax file to programmatically specify which provider to use for a specific request. The following example shows how to do this.

public override string GetOutputCacheProviderName(HttpContext context)
{
if (context.Request.Path.EndsWith("Advanced.aspx"))
return "DiskCache";
else
return base.GetOutputCacheProviderName(context);
}

With the addition of output-cache provider extensibility to ASP.NET 4, you can now pursue more aggressive and more intelligent output-caching strategies for your Web sites. For example, it is now possible to cache the “Top 10” pages of a site in memory, while caching pages that get lower traffic on disk.



ASP.NET Hosting - ASPHostPortal.com :: 5 Tips to Check Before Choose FREE ASP.NET Hosting Provider

clock May 11, 2016 21:22 by author Armend

5 Tips to Check Before Choose FREE ASP.NET Hosting Provider

Hosting Account Setup

After you place an order of web hosting you should get hosting account instantly or it should not be delayed more than 12 hours and the another thing there is very little effort required in creating a new hosting service so it should be free. But you can see so many web hosts charge you money as a setup fee that's just silly.

 

Web Space and Bandwidth

As you might aware web resources are always limited like there is fixed amount and quantity of hard drive, ram, cpu in the web server and looking for unlimited package is just a impractical idea. Ftp or upload complete personal website data to your hosting space you require only 20mb web space to 100mb web space maximum so why looking for unlimited features? Most of cheap unlimited hosting providers have data server outage issue repeatedly so selecting unlimited web hosting in cheap price can cease your expensive website data.

Technical support for customers

There is already big giant in web hosting, cheap hosting and free hosting industry which have very professional sales team for the clients and they use all mode of support system for the new clients via phone, live chat, ticket, email, voip but when it is the time to raise a technical issue concerned to your hosting account that time there would be the problem and so many of your hosting issue wont be resolved by their technical customer support. So besides searching for cheap hosting price you should also look for skilled and good customer support system for tech.

Control Panel and Hosting Features

Various control panel for web disk are available and many are worst and few are excellent and easy to manage. Mostly client had issue with windows panel like plex and cpanel is very familiar. Many hosts provide multiple domains hosting in a single hosting account which is cheap and easy to handle but when you require is to transfer or migrate your hosting account from old hosting to new hosting in that time probably there would be the problem. In your hosting you should look for database, ftp, php, phpMyadmin, MySql, application installer, virus scanner, email accounts, subdomain, folder locker, url forwarding, backup, seo tool etc at free of cost without upgrades.

Always Read the Terms and Conditions

You are agreed with terms and conditions before you start hosting with them so make sure you read all the terms, refund policy, money laundering policy, resource abuse policy, privacy policy etc.

 



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