All About ASP.NET and ASP.NET Core 2 Hosting BLOG

Tutorial and Articles about ASP.NET and the latest ASP.NET Core

ASP.NET Hosting - ASPHostPortal :: Step by step instructions to disable Session state on your ASP.NET page

clock February 9, 2015 06:43 by author Dan

Each ASP.NET page has the session state of course, this may diminish the aggregate execution a tad bit. So You can incapacitate the session state from the pages when you don't have to utilize sessions. What's more you can do as such to set the false estimation of the EnableSessionState characteristic in the page mandate of your page like as:

<%@ page EnableSessionState="False" %>

Full deceleration:

<%@ Page Title="Home Page" Language="C#" EnableSessionState="False"
AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

Essentially EnableSessionState can have three qualities: False, ReadOnly and True. Assume on the off chance that you need to peruse the qualities from the session at exactly that point you can set the ReadOnly to the EnableSessionState characteristic.
Also Now on the off chance that you need to handicap Session state on whole site then you can change your site's web.config document by simply including after lines

<configuration>

    <system.web>
        <sessionState mode="Off">
        </sessionState>
        </system.web>
    </configuration>


When you set the handicap session state from the web.config, after that you can utilize the EnableSessionState="True" in any page of your site.

Best ASP.NET 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 :: Automatically Clean Up Temporary ASP.NET Files

clock February 6, 2015 06:24 by author Dan

The Problem

One of the test situations I help keep up is subject to dynamic and general changes in .NET applications. The improvement group are always discharging new forms that are marginally distinctive.

You may not be mindful that .NET applications experience an assemblage process when they first start up. I've additionally been told on application pool reuse anyway I haven't affirmed this. Then again, after the application has been evacuated or overhauled, the arrangement interim records remain. On a test situation like my above situation, an aggregate of 50gb of circle space can be effortlessly squandered, doing nothing. So in case you're in a comparable situation, you may need to routinely clean up these records.

I know of four areas where these records can develop:

  • C:\Windows\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files
  • C:\Windows\Microsoft.NET\Framework64\v1.1.4322\Temporary ASP.NET Files
  • C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files
  • C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files
  • C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files
  • C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files

On the off chance that you application pools run in 64bit mode, you'll discover the "Framework64″ areas more appropriate. In the event that your application pools utilize 32bit mode, you'll have to consider the "Structure" areas.

The following is an illustration of a creation domain utilizing almost 13gb:

Powershell Script to Automatically Delete Temp Files

As framework directors, we have to robotize and script our workload so we can concentrate on the vital stuff! So we formulated a basic execution of Powershell script which deals with this clean up issue in one line:

Get-Childitem "C:\windows\microsoft.net\framework*\v*\temporary Asp.net Files" -Recurse | Remove-Item -Recurse

In case you're perusing this and considering, EWWWW Powershell. Don't deride it until you attempt this single line summon.

I spared the above charge into a record names Cleanupaspnettempfiles.ps1 and spared it to D:\tools\. Name and recovery yours as you see fit.

To relax, you can plan this script with a planned assignment. You can click on these screenshots in the event that you require more detail:

(I picked to run on the first Saturday of the month. Utilize your own inclination.)

(My powershell.exe was at %systemroot%\system32\windowspowershell\v1.0\powershell.exe)

(Note you have to tick the choice box to get to the following screenshot or burden the properties on the recently made undertaking.)

Execution Policy Errors

In case you're being advised to sign your recently made script, you can either do that for high security situations or you can turn off the marking prerequisite. It's extraordinary to have this choice incorporate with the dialect yet in the commonplace environment I've discovered it a trouble.

In a Powershell summon window, sort the accompanying to check your current Executionpolicy:

Get-Executionpolicy

You can transform it to Unrestricted by writing:

Set-Executionpolicy Unrestricted

A Few Notes

An update that records in these areas are typical. Don't go over the top attempting to clean them up.

It ought to be noted that while the records are being used by the web server, you won't have the capacity to erase them – this is fine; the objective is to clean up unused documents.

You ought to additionally be mindful whenever the application wakes up, on application pool begin, the application will re-gather once more. This may prompt a more drawn out than normal starting page load. On the off chance that this is of concern, consider just uprooting records that are more seasoned than 30 days.

Obviously, this script is given as may be. You ought to test it completely in a test situation before utilization underway (however I surely do).

Best ASP.NET 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 :: Describes Caching Methods In ASP.NET

clock February 5, 2015 06:45 by author Mark

Today I will describes caching methods in ASP.NET. It's a good habit to use caching in your application and coding standards too.

Overview

Caching is one of the most interesting concepts and operations in ASP.NET. If you can handle it, you can run any web application by applying the caching concept depending on the requirements.
Currrently a majority of websites/portals (or I can say simply web pages) are dynamic (if I do talk about a dynamic website, then it doesn't mean all the pages of that website is dynamic or will be. The probability of happening this is dependent on the user's perspective and the requirements).
In veru common words I can define dynamic pages as including the following:

  • Pages that directly interact with people
  • Communication (on page)
  • Any media content
  • Any Type of grafic Interaction

So, generally these types of pages or webs are called dynamic. Now let's find why we really need caching.

Why Caching

Caching is for providing solutions or the results to the users depending on their requested request, admin needs to recreate the pages often depending on user requests…STOP!!!

The process

The process is quite bulky and time-consuming. So to overcoming that problem some websites have a page creation engine that automatically creates all the pages in one action and directly saves those pages as a HTML structured page. These HTML pages serve the user depending on their requirements.

Multiple sorts of pages

But, do you still think this will be enough? If your answer is yes, then please think some more!
Actually, the preceding solution will only work if and only if the requested pages are of the same type. Now think, what will happen if the users request a different sort of page?
In that case your web will be stuck again.
So for dealing with that kind of complex but necessary requirements, ASP.NET provides support for caching. Caching is the hero/heroine in this context that will help us to a great extent.

What a Cache does

What a cache does, in the most simple words I can say is:
"A cache simply stores the output generated by a page in the memory and this saved output (cache) will serve us (users) in the future." That's it.

Types

Page Caching

Let's explore the caching of an entire page, first.
To cache an entire page's output we need to specify a directive at the top of our page, this directive is the @ OutputCache.
Let's figure out a simple demo of it.

<%@ OutputCache Duration = 5 VaryByParam = "ID" %> 

Here, in that statement Duration and VarByParam are the two attributes of the OutputCache directive. Now let's explore how they work.

  • Duration Attribute : This attributes represents the time in seconds of how long the output cache should be stored in memory. After the defined duration the content stored in the memory will be cleared automatically.
  • VarByParam Attribute : This is the most important attributes; you can't afford to miss that in the OutputCache directory statement. It generally defines the query string parameters to vary the cache (in memory).

You can also pass multiple parameter names too, but for that you need to separate them using a semicolon (;).
You can also specify it as "*". In this case the cached content is varied for all the parameters passed using the querysrting.
For example:

<%@ OutputCache Duration = 5 VaryByParam = "*"%> 

In case of caching a page, some pages can generate different content for different browsers. In that scenario we need to add an additional attribute to our statement for overcoming the preceding problem.
For example:

<%@ OutputCache Duration = 5 VaryByParam = "ID" VaryByCustom = "Browser" %> 

Or:

<%@ OutputCache Duration = 5 VaryByParam = "*" VaryByCustom = "Browser" %>

Fragment caching

In some scenarios we only need to cache only a segment of a page. For example a contact us page in a main page will be the same for all the users and for that there is no need to cache the entire page.
So for that we prefer to use fragment caching option.
For example:

<%@ OutputCache Duration = 10 VaryByParam = "None" %> 

Or:

<%@ OutputCache Duration = 5 VaryByParam = "None" VaryByCustom = "Browser" %> 

Data Caching

Data caching is slightly different from the 2 other caching types. It's much more interesting to see how data caching actually works.
As we know in C# everything is about classes and objects. So ASP.NET supports data caching by treating them as small sets of objects. We can store objects in memory very easily and use them depending on our functionality and needs, anywhere across the page.
Now you must be thinking where is the class in that entire scenario?
Actually, this feature is implemented using the Cache class and data is treated as its object. Let's see how it works using a demo.

I am inserting a string value in the cache as:

Cache["Website"] = "CSharpCorner"; 

Now, for inserting the cache into the objects, the insert method of the Cache class can be used. This insert method is used as follows:

Cache.Insert("Website", strName, 
new CacheDependency(Sever.MapPath("Website.txt")); 

What we are missing something
We missed the Time for the cache (don't forget to use it), let's provide it:

Cache.Insert("Website", strName, 
new CacheDependency(Sever.MapPath("Website.txt") 
DateTime.Now.Addminutes(5), TimeSpan.Zero); 

Happy coding!

TOP No#1 Recommended ASP.NET Hosting

ASPHostPortal.com

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



ASPHostPortal.com Announces Fast Kentico 8.2 Hosting Solution

clock February 3, 2015 11:27 by author Dan

Supported by professional teams, ASPHostPortal has been gaining more and more user’s recognition. We offers 4 main packages with different prices. All the packages include large bandwith, large disk space, latest ASP.NET technology, free data backups, uptime guarantee, dedicated application pool and much more. Today, we launch Kentico 8.2 hosting with superior technology and affordable price.

Kentico CMS is a web content management system (WCMS) for building web sites, on-line stores, intranets and Web 2.0 community sites. Kentico is being used by more than 16,000 Web sites in 90 countries. Kentico CMS utilizes ASP.NET and Microsoft SQL Server. Kentico allows development via its portal engine or using Visual Studio. Kentico is also compatible with Microsoft Windows Azure Platform.

Kentico 8.2 featuring several new collaboration and ecommerce enhancements that make launching and managing digital marketing campaigns faster and easier than ever. The latest product enhancements include:

Bi-Directional SharePoint Synchronization
all changes made in Kentico will be made automatically on the SharePoint server. Just point and share the files are always up to date, and everyone has the latest versions.

Easy Shipping Calculations
Everyone can now easily create a shipping module (and reuse for other projects) that presents all the tools that need to calculate shipping costs in custom user interface.

Enhanced Contact Management
Everyone can easily import Contacts from a CSV file, segment them, and leverage them in the system.

With more than 1 million followers, ASPHostPortal is an expert in the hosting market. We provide Kentico 8.2 Hosting only from $5/month with 30 days money back guarantee. In addition, we have been awarded as one of the fastest hosting companies in the industry because of the good hosting performance our web host provides. To provide fast hosting speed, we utilize 6 state-of-the-art data centers located on the USA, Netherlands, Singapore, France, United Kingdom and Australia. To learn more about Kentico 8.2 Hosting, please visit http://asphostportal.com/Kentico-8-2-Hosting

About ASPHostPortal.com :
ASPHostPortal.com is The Best, Cheap and Recommended ASP.NET Hosting. ASPHostPortal.com has ability to support the latest Microsoft and ASP.NET technology, such as: 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 include shared hosting, reseller hosting, and sharepoint hosting, with speciality in ASP.NET, SQL Server, and architecting highly scalable solutions. ASPHostPortal.com strives to supply probably the most technologically advanced hosting solutions available to all consumers the world over. Protection, trustworthiness, and performance are on 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 MVC Hosting - ASPHostPortal.com :: How to Create Various Charts for ASP.NET MVC Applications

clock February 3, 2015 06:02 by author Mark

How to Create Various Charts like Line, Column, Area and Pie for ASP.NET MVC Applications.

In this article we will see how to create various charts like Line, Column, Area and Pie for ASP.NET MVC applications. In this article we will use a third party chart control so you will also learn how to use the third party control in ASP.Net MVC application. In my last two articles i.e. Display Graph in ASP.NET MVC and Charts for Asp.Net Application you saw how to prepare the chart/graph for ASP.Net and ASP.Net MVC. Charts for Asp.Net Application here I'm using some third party chart control to prepare the chart for ASP.Net. In this article also I'm using the same chart control with a MVC application. In a normal ASP.Net application all of you are aware of using third party controls in your application but in MVC it is slightly different.
In this article we will create four different kinds of charts as mentioned below.

  • Line Chart
  • Column Chart
  • Pie Chart
  • Area Chart

Step 1 :  For creating these various charts in our application we use the WebChart.dll file so simply download the attachment and add the reference to your project.
Step 2 : Add the controller Home in your project and write the different methods for calling different charts like below.

public ActionResult Index()
       {
             return View();
        }
        public ActionResult Line()
        {
            return View();
        }
        public ActionResult Area()
        {
            return View();
        }
        public ActionResult Pie()
        {
            return View();
        }
        public ActionResult Column()
        {
            return View();
        }

Step 3 : Now add the View for index and keep the Action links for calling different methods in Home controller like below.

<%=Html.ActionLink("Line Chart","Line") %>
<%=Html.ActionLink("Area Chart","Area") %>
<%=Html.ActionLink("Pie Chart","Pie") %>
<%=Html.ActionLink("Column Chart","Column") %>

Step 4 : First, on the top of the page, register one tag prefix to refer to the WebChart.dll and import the namespaces i.e. WebChart and System.Drawing like below.

<%@ Register TagPrefix="Web" Namespace="WebChart" Assembly="WebChart" %>
<%@ Import Namespace="WebChart"%>
<%@ Import Namespace="System.Drawing"%>

Step 5 : In the head section of your view write the following script.

<script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {              
                AreaChart chart = new AreaChart();
                chart.Fill.Color = Color.FromArgb(50, Color.SteelBlue);
                chart.Line.Color = Color.SteelBlue;
                chart.Line.Width = 2;
                chart.Legend = "The Legend What You Want";
                //can pull the values from database             
                chart.Data.Add(new ChartPoint("Vulpes", (float)System.Convert.ToSingle(350)));
                chart.Data.Add(new ChartPoint("SP Nayak", (float)System.Convert.ToSingle(185)));
                chart.Data.Add(new ChartPoint("Krishna", (float)System.Convert.ToSingle(55)));
                chart.Data.Add(new ChartPoint("Datta Kharad", (float)System.Convert.ToSingle(40)));
                chart.Data.Add(new ChartPoint("Jignesh Trivedi", (float)System.Convert.ToSingle(30)));
                chart.Data.Add(new ChartPoint("Prabhu Raja", (float)System.Convert.ToSingle(25)));
                ConfigureColors();
                ChartControl1.Charts.Add(chart);
                ChartControl1.RedrawChart();
            }
        }
        private void ConfigureColors()
        {
            ChartControl1.Background.Color = Color.FromArgb(75, Color.SteelBlue);
            ChartControl1.Background.Type = InteriorType.LinearGradient;
            ChartControl1.Background.ForeColor = Color.SteelBlue;
            ChartControl1.Background.EndPoint = new Point(500, 350);
            ChartControl1.Legend.Position = LegendPosition.Bottom;
            ChartControl1.Legend.Width = 40;
             ChartControl1.YAxisFont.ForeColor = Color.SteelBlue;
           ChartControl1.XAxisFont.ForeColor = Color.SteelBlue;
             ChartControl1.ChartTitle.Text = "C-Sharpcorner Current Months Runner Up";
            ChartControl1.ChartTitle.ForeColor = Color.White;
             ChartControl1.Border.Color = Color.SteelBlue;
            ChartControl1.BorderStyle = BorderStyle.Ridge;
        }
    </script>

In the above code we have populated the chart control by adding chart points. You can add your own chart points. This Webchart.dll provides the different types of charts we discussed above so according to your view make a change in the first line under page load by creating different classes instance of chart type e.g.:

For Area Chart use

AreaChart chart = new AreaChart();

For Line Chart use

LineChart chart = new LineChart();

In the above code you only have to make these changes for creating your own choice chart also you can configure the colors as you need and you can create the points i.e. chart point per your requirement.

Step 6 : Add four views with each chart type by replacing the classes of WebChart. Now run your application and see the results.

Conclusion

It is quite simple to create various types of charts for our ASP.Net MVC applications.

TOP 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.



ASP.NET Hosting - ASPHostPortal.com :: Sending an email using exchange server from the ASP.NET Application

clock February 2, 2015 07:27 by author Dan

The .NET Framework 1.x had a System.web.mail class to send an email from the ASP.NET system. While this namespace and these classes still exist in the .NET Framework form 2.0 and later, they have been expostulated and supplanted by the new Mail API in the System.net.mail namespace in the Asp.net 2.0 structure. Asp.net 1.x's System.web.mail API was focused around CDO libraries. With the new Apis, Microsoft moved far from CDONTS based wrapper Apis and composed the new API utilizing Com+ segments to enhance the execution.

ASP.NET 2.0 sends an email utilizing Smtpclient class. In the most fundamental arrangement, You need to set the hostname of the hand-off server in the event that you are utilizing trade server or localhost in the event that you are utilizing neighborhood SMTP administration, port (25 as a matter of course), authentican certifications, or pointed out pickup index through the Deliverymethod property.

Here is the template for the System.NET.Mail configuration.

<configuration>
<!– Add the email settings to the element –>
<system.net>
<mailSettings>
<smtp deliveryMethod=”PickupDirectory” from=”fromemailaddress”>
<network
host=”relayServerHost”
port=”portNumber”
userName=”username”
password=”password”
defaultCredentials=”true/false”/>
</smtp>
</mailSettings>
</system.net>
</configuration>

localhost – local web server SMTP administration – If you need to send an email through neighborhood SMTP Service of the web server, basically include emulating lines of code in your web.config to send an email from the ASP.NET Pages.

<system.net>
<mailSettings>
<smtp deliveryMethod=”PickupDirectoryFromIis”>
<network host=”(localhost)” port=”25″ defaultCredentials=”true” />
</smtp>
</mailSettings>
</system.net>

Exchange Server – If you need to send an email from existing trade server email account, you need to setup the transfer administration from your webserver to trade server. Emulating web.config setup permits you utilize hand-off administration for trade server.

How about we say's exchange server name is "exmail.domainname.com", exchange username and secret key is "exchangeuserid" and "exchangepassword", you web.config settings would be

<system.net>
<mailSettings>
<smtp>
<network host=”exmail.domainname.com” port=”25″ userName=”exchangeuserid” password=”exchangepassword” defaultCredentials=”false” />
</smtp>
</mailSettings>
</system.net>

Next step would be to make a class to send a messages utilizing SMTP Service: Note that emulating code utilizes Web.config settings. Remarked out code won't utilize web.config mail settings. In spite of the fact that its preferrable, on the off chance that you don't need email designs in web.config document, utilize the remarked out code to design and send an email from the ASP.NET pages.

using System;using System.Net;using System.Net.Mail;
public class SMTPEmailSender
{
public SMTPEmailSender()
{
//
// TODO: Add constructor logic here
//
}

public static void SendSMTPEmail(string senderMailAddress,
string recipientMailAddress,
string mailSubject,
string mailBody)
{

//Create MailMessage to send an email.
MailMessage message = new MailMessage(senderMailAddress, recipientMailAddress);
message.Subject = mailSubject;
message.Body = mailBody;

//Use SMTPClient to send an email.
//Uses SMTP settings from web.config
SmtpClient client = new SmtpClient();
client.Send(message);

//Uses SMTP Settings from Code
/*
//Sample Code
//SmtpClient smtp = new SmtpClient(“exmail.domainname.com”, portnumber);
//smtp.Credentials = new NetworkCredential(“exchangeuserid”, “exchangepassword”, “DOMAIN”);
//smtp.DeliveryMethod = SmtpDeliveryMethod.Network; //smtp.Send(message);
*/
}
}

Create a Test Page to send out emails. Here is the source code from the code behind to send an email from the test email page.

public partial class TestEmail : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string fromEmailAddress = “admin@exmail.domainname.com“;
string recipientEmailAddress = “niks@test.com“;
string mailSubject = “Nik’s Website: Test Email”;
string mailBody = “Test Email.”;
if (recipientEmailAddress != null && recipientEmailAddress.Trim().Length != 0)
{
SMTPEmailManager.SendSMTPEmail(fromEmailAddress, recipientEmailAddress, mailSubject, mailBody);
}
Response.Write(“Test Email Sent Out”);
}
}

Best ASP.NET 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.



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

 photo ahp banner aspnet-01_zps87l92lcl.png

 

Corporate Address (Location)

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

Tag cloud

Sign in