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 - Resolve Errror "Validation of viewstate MAC failed"

clock March 5, 2013 08:57 by author andy_yo

Usually we won’t got “Validation of viewstate MAC failed” error in our site all the time. Normally the site works fine and doesn't throw any errors if you load the site and use it at a regular pace.  The error only occurs when you load the page, leave it for a while, and then continue working on the page without reloading or refreshing it.  I discovered this error because I opened the site, began using it, left for lunch, came back an hour later, and when I resumed using it and did anything that caused postback, it immediately threw the above error.  Unfortunately in order to re-create the error, I have to wait a while, which is very inconvenient for testing/troubleshooting. After a few hours of reasearch I found the solutions:

About ASPHostPortal.com

ASPHostPortal.com is Microsoft No #1 Recommended Windows and ASP.NET Spotlight Hosting Partner in United States. Microsoft presents this award to ASPHostPortal.com for ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2012, ASP.NET 4.5, ASP.NET MVC 4.0, Silverlight 5 and Visual Studio Lightswitch. Click here for more information

Error message:

Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.

Solution:

Yet another very teasing issue ASP .Net developers face. Solution is pretty much simple.

Add following link in your web.config file.

<pages enableEventValidation="false" viewStateEncryptionMode="Never" />

Above line should be included within section.

OR

if you don't want this solution to implemented on project level then you can add these attribute to the page(Top most line of HTML view) directive of the page which is creating issue.

That means you have to add enableEventValidation="false" viewStateEncryptionMode="Never" in page directive.

 



ASP.NET Hosting - How To Make URL More User Friendly (URL Rewriting)

clock February 27, 2013 05:24 by author andy_yo

Sometimes we need a user friendly URL, but if we use query string variables, our site url will become messy.

Like we may be having

URL A: http://www.asphostportal.com/product.aspx?id=123456

and we want to have a URL for above as

URL B: http://www.asphostportal.com/product_123456.aspx

Obviously from above two the 2nd one is more user friendly and easily readable. Now the question is how to accomplish this task. The solution is very simple. In following I will be explaining the solution in detail

About ASPHostPortal.com

ASPHostPortal.com is Microsoft No #1 Recommended Windows and ASP.NET Spotlight Hosting Partner in United States. Microsoft presents this award to ASPHostPortal.com for ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2012, ASP.NET 4.5, ASP.NET MVC 4.0, Silverlight 5 and Visual Studio Lightswitch. Click here for more information

The Solution

Though there are more than one ways for this task but I will make use of the method "application_beginrequest" of "Global.asax". This method is called every time some request is made to the website.

Following will be the code to convert URL A into URL B in VB and C# programming language. You can modify this code as per your need.

VB

Public Sub application_beginrequest(ByVal sender As Object, ByVal e As EventArgs)
     Try
        Dim initialurl As String = Request.Url.ToString
        If initialurl.ToLower.IndexOf("product_") >= 0 Then
            Dim mTemp As String = initialurl.Substring(initialurl.LastIndexOf("_") + 1)
            Dim mProductID As Integer = mTemp.Substring(0, mTemp.LastIndexOf(".aspx"))
            Dim mOriginalURL As String = "product.aspx?id=" + mProductID
            Context.RewritePath(mOriginalURL)
        End If
        'Code to Log your Error
     Catch ex As Exception
     End Try
End Sub

CSharp (C#)

public void application_beginrequest(object sender, EventArgs e)
{
    try
    {
        string initialurl = Request.Url.ToString();
        if (initialurl.ToLower().IndexOf("product_") >= 0)
        {
            string mTemp = initialurl.Substring(initialurl.LastIndexOf("_") + 1);
            int mProductID = Convert.ToInt32(mTemp.Substring(0, mTemp.LastIndexOf(".aspx")));
            string mOriginalURL = "product.aspx?id=" + mProductID;
            Context.RewritePath(mOriginalURL);
        }
    }
    catch (Exception ex)
    {
        //Code to Log your Error
    }
}



ASP.NET Hosting - How to add favicon to your ASP.NET page

clock February 8, 2013 11:09 by author andy_yo

A favicon is the little image displayed at the left edge of the address bar in most browsers, or on the tab. Adding a Favicon is a nice way to enhance your website and give it a finished look.

About ASPHostPortal.com

ASPHostPortal.com is Microsoft No #1 Recommended Windows and ASP.NET Spotlight Hosting Partner in United States. Microsoft presents this award to ASPHostPortal.com for ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2012, ASP.NET 4.5, ASP.NET MVC 4.0, Silverlight 5 and Visual Studio Lightswitch. Click here for more information


Firefox displaying favicon:

Google Chrome displaying favicon:

 

Interner Explorer displaying favicon:

Adding a favicon to your website is very easy. First you need to create a 16 by 16 pixel icon and name it favicon.ico. No other file format or size will do. Save your favicon to the root directory of your ASP.Net web application:


In some older browsers (e.g., Internet Explorer 5), that's all it takes. For the latest versions of Firefox, Internet Explorer and Chrome, however, you need to add two links to your favicon to the head in your HTML. If you are using a master page, the same two links would go in the head on the master page.:

                <head runat="server">
                <
title>My Website</title>
                <
link runat="server" rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
                <
link runat="server" rel="icon" href="favicon.ico" type="image/ico"/>
          </
head>


The reason you have two links to the same favicon is to make sure your favicon works with most browsers. Some, such as Firefox, will work with either link. Internet Explorer versions 6 and 7 are especially picky. If you use both links, however, one is bound to work in almost any browser.



NOP Commerce Hosting - Create NOP Commerce Theme

clock January 23, 2013 08:30 by author andy_yo

This tutorial does not require Visual Studio and does not need any type of recompile of the nopCommerce code. You can do everything in this tutorial with notepad and access to the file system nopCommerce is installed in (FTP, network, SCP, etc).

About ASPHostPortal.com

ASPHostPortal.com is Microsoft No #1 Recommended Windows and ASP.NET Spotlight Hosting Partner in United States. Microsoft presents this award to ASPHostPortal.com for ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2012, ASP.NET 4.5, ASP.NET MVC 4.0, Silverlight 5 and Visual Studio Lightswitch. Click here for more information

This tutorial applies to:

nopCommerce 2.0, nopCommerce 2.1, nopCommerce 2.2, nopCommerce 2.3

To get started you are going to copy one of the pre-existing themes and use it as the base of your new theme. So go to the root of your nopCommerce store and drill down to the theme section.

[root]/NopCommerceStore/Themes/

Step 1 – Copy the Directory

Here you should see a couple of themes, which themes exactly depend on the version of nopCommerce you are using. I recommend selecting “NopClassic” or “darkOrange”, and copy either one in the theme directory as a copy. Then rename that directory.

Step 2 – Edit “theme.config”

Update “theme.config” (\Themes\YourThemeName\theme.config) and update the title, the rest of the XML doesn’t impact the display of the theme. This just effects the title on the theme drop down in the admin section. If you leave it the same you will not able to tell which theme is which. So the file should now look something like this after you have edited it.

 

Step 3 – Edit “head.cshtml”

Now updated the “head.cshtml” file (\Themes\YourThemeName\Views\Shared\Head.cshtml). This is the real gotcha for me, missing this step will make your new theme directory appear as if it is stuck using the theme you copied it from. Change both of the “link href” values to reflect the directory of your new theme. In my case it looked like this.

Step 4 – Select Theme in nopCommerce Admin

Once you have completed this step update the nopCommerce Admin to reflect the fact that you wish to use your new theme. If you don’t see your theme listed, restart IIS. NopCommerce has its own internal caching algorithium and it can take some time to notice an updated to the backend like this one.

Any changes you want to make to your copied theme can now be done. The important directories and files for the designers in the audience are…

Main CSS File

[root]/NopCommerceStore/Themes/YourThemeName/Content/styles.css

Images and Media

[root]/NopCommerceStore/Themes/YourThemeName/Content/images



Windows Server 2012 Hosting - Top 10 Windows Server 2012 Features

clock January 17, 2013 10:26 by author andy_yo

Many IT professionals and system administrators are evaluating the software for deployment Windows Server 2012 since it has been officially available in September 9th, 2012. Here are the top 10 features that we think noteworthy new (or improved) features in Windows Server 2012.

About ASPHostPortal.com

ASPHostPortal.com is Microsoft No #1 Recommended Windows and ASP.NET Spotlight Hosting Partner in United States. Microsoft presents this award to ASPHostPortal.com for ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2012, ASP.NET 4.5, ASP.NET MVC 4.0, Silverlight 5 and Visual Studio Lightswitch. Click here for more information

Top 10 Windows Server 2012 Features

1. Data Deduplication

One of the constants of technology and the IT industry is that data storage demands and requirements are increasing exponentially. From ballooning email inboxes to file shares overflowing with documents, just about every enterprise has a need for more efficient. That’s where the new data deduplication features in Windows Server 2012 come in handy.

It works like this: Say you have a large number of VHD (virtual hard disk) files that you need to move. Each of those VHDs has a lot of duplicate (yet identical) files and applications, like minesweeper, Windows calculator, and other accessory applications. Data deduplication removes all of the copies of those applications from those VHDs but one. It then records the redundant data in a separate location in System Volume Information (SVI) and points to the files that serves as the source template. This can free up tremendous amounts of space, especially when applied across thousands of files across your network. Data deduplication works across different computer networks and also across Windows 8 and Windows Server 2012 machines. If you have lots of files and data to store and not enough space – and who doesn’t – this could be the killer feature.

2. GUI-less install options

There are plenty of times when you only want to install only the absolute minimum files and assets you need to run Windows Server, and Windows Server 2012 now includes a default installation option to install the GUI-less server core. You can also now install Windows Server 2012 with a minimal user interface, which means that you have even more ways than ever to install just the Windows Server files you need. This reduces disk space, saves on administration effort, and reduces your attack surface from hackers and other digital malcontents by restricting installed files to the absolute minimum.

3. Hyper-V 3.0

Windows Server 2012 is loaded with new features, but perhaps the feature that has gone through the most radical improvement is the Hyper-V virtualization feature set. Tired of playing catch-up to VMware on the feature front, Microsoft has loaded Hyper-V with an impressive list of improvements. Some of the highlights include support for up to 64 processors and 1TB of RAM per virtual machine, as well as support for up to 320 logical hardware processors and 4TB of RAM per host. VMware vSphere 5.1 evens the playing field in some areas, but the message is clear: Microsoft is doing everything it can to unseat VMware as the virtualization platform of choice in the enterprise.

4. IP Address Management (IPAM)

One of the biggest headaches for many IT professionals is keeping tabs on IP addresses used on their corporate networks. In a bid to end the time-honored practice of storing IP addresses in Excel spreadsheets, IPAM is a new feature in Windows Server 2012 that provides a new internal framework for locating and managing IP address spaces on networks. You can also manage and monitor servers running Domain Name Service (DNS) and Dynamic Host Configuration Protocol (DHCP). It also does automatic IP discovery and provides a host of other IP-related tasks focused on management, monitoring, and auditing.

5. Network virtualization changes

One of the more problematic aspects of virtual machine management and provision is dealing with the rules and limitations of IP address management. Microsoft is making a raft of improvements to network virtualization in Windows Server 2012, all aimed at tackling problems related to IP addresses and virtual machines. This helps pave the way for private cloud adoption, and also removes barriers for more infrastructure as a service (IaaS) adoption easier for internal IT stakeholders and hosting customers to implement.

6. ReFS

The venerable NTFS file system format has been used for more than a decade by Microsoft. Recent demands from virtualization and private cloud computing have pushed NTFS as far as it could go, so Microsoft decided to add new features and revamp existing ones to NTFS. The result is an upgrade to NTFS dubbed Re-FS for resilient file system.

Re-FS adds a bumper crop of new storage features and improvements, with some of the highlights being increased support for larger file and directory sizes, disk scrubbing, data striping for improved performance, enhanced virtualization support, and it takes advantages of all the new storage pool and spaces features in Windows Server 2012.

7. Shared nothing live migration

One of the more impressive new features of Hyper-V 3.0 is shared nothing live migration, which allows you to move VMs from one machine to another without the requirement of having shared storage before making the transfer. This feature can be a boon for smaller IT departments, and it makes it easy to move VMs around without expensive share storage. It one of the most impressive features in Windows Server 2012, and it will help small- to mid-size IT departments become even more agile and responsive to business and customer needs.

8. Storage pools and spaces

Most IT departments have to contend with a dizzying assortment of storage hardware and medium types, from leading-edge SSD drives and spinning disks to removable drives and legacy magnetic reel tape. Making effective use of all those disparate storage formats can sometimes be a Herculean task, especially when you throw in the ever-increasing storage demands that today’s workplaces place on IT departments. Microsoft is hoping to help admins address that by introducing Storage Pools and Spaces, two storage abstractions concepts being introduced in Windows Server 2012.

Storage Pools aggregate these heterogeneous physical storage devices into cohesive units where it’s relatively easy to add storage capacity by adding additional storage. As mentioned previously, the devices in storage pools don’t have to be homogenous from the perspective of either device or storage size; you can mix and match devices and sizes here.

Storage Spaces takes that concept even further by allowing you to create virtual disks that have the same characteristics as physical devices: they can be attached, removed, backed up, and otherwise managed exactly the same as traditional physical disks. But Spaces have even more useful features and capabilities, including enhanced capabilities when combined with virtualization and private cloud solutions. They also have additional capabilities on the backup, recovery, and high-availability front, and improvement in the realm of thin provisioning as well.

9. PowerShell 3.0

PowerShell has been steadily gaining in popularity over the last few years, and Microsoft pulled out all the stops for PowerShell support in Windows Server 2012. More than 2000 PowerShell cmdlets are now included, and the newly enhanced stable of commands allows IT professionals to automate and control more aspects of their Windows Server 2012 environment through the PowerShell command line that ever before. This latest update to PowerShell also included improved web access, the ability to schedule jobs, support for disconnected sessions, enhanced and editable help files, and dozens of other new features.

10. CHKDSK changes

Everyone reading this is probably already intimately familiar with the ubiquitous CHKDSK application, which has been in use in various forms since MS-DOS 1.0. We’ve all stepped out for a cup of coffee when the dreaded CHKDSK disk scan kicks off on a server or client equipped with large disk storage.

Microsoft has responded to this productivity killer by revamping CHKDSK in Windows Server 2012. Rather than spending vast amounts of time laboriously scanning through sectors on large disks, the new and improved CHKDSK now scans disks in two phases: An online phase that detects errors and logs defects (and which also can run in the background), and an actual repair phase that does the actual fixing of corrupted drive data.



ASP.NET Hosting - ASPHostPortal :: How to Add Custom Event in Web User Control

clock December 15, 2010 03:46 by author Jervis

It’s easy and you just need to follow this steps:

1. Declare event in the user control


public EventHandler AddNew;

2) Fire that event form user controls event.

if (AddNew != null)
AddNew(sender, e);


(like button click event in that control.)

3) Now asign that event in Page_OnInit event for that control.

protected override void OnInit(EventArgs e)
{
myUserCotrol1.AddNew = new EventHandler(MyNewEventMethod);
}


4) Now wight down that method in which one you declared in page onInit event

protected void MyNewEventMethod (object sender, EventArgs e)
{
//Some code;
//Some code;
}


Done!!!!

Reasons why you must trust ASPHostPortal.com

Every provider will tell you how they treat their support, uptime, expertise, guarantees, etc., are. Take a close look. What they’re really offering you is nothing close to what ASPHostPortal does. You will be treated with respect and provided the courtesy and service you would expect from a world-class web hosting business.

You’ll have highly trained, skilled professional technical support people ready, willing, and wanting to help you 24 hours a day. Your web hosting account servers are monitored from three monitoring points, with two alert points, every minute, 24 hours a day, 7 days a week, 365 days a year. The followings are the list of other added- benefits you can find when hosting with us:

- DELL Hardware
Dell hardware is engineered to keep critical enterprise applications running around the clock with clustered solutions fully tested and certified by Dell and other leading operating system and application providers.
- Recovery Systems
Recovery becomes easy and seamless with our fully managed backup services. We monitor your server to ensure your data is properly backed up and recoverable so when the time comes, you can easily repair or recover your data.
- Control Panel
We provide one of the most comprehensive customer control panels available. Providing maximum control and ease of use, our Control Panel serves as the central management point for your ASPHostPortal account. You’ll use a flexible, powerful hosting control panel that will give you direct control over your web hosting account. Our control panel and systems configuration is fully automated and this means your settings are configured automatically and instantly.
- Excellent Expertise in Technology
The reason we can provide you with a great amount of power, flexibility, and simplicity at such a discounted price is due to incredible efficiencies within our business. We have not just been providing hosting for many clients for years, we have also been researching, developing, and innovating every aspect of our operations, systems, procedures, strategy, management, and teams. Our operations are based on a continual improvement program where we review thousands of systems, operational and management metrics in real-time, to fine-tune every aspect of our operation and activities. We continually train and retrain all people in our teams. We provide all people in our teams with the time, space, and inspiration to research, understand, and explore the Internet in search of greater knowledge. We do this while providing you with the best hosting services for the lowest possible price.
- Data Center
ASPHostPortal modular Tier-3 data center was specifically designed to be a world-class web hosting facility totally dedicated to uncompromised performance and security
- Monitoring Services
From the moment your server is connected to our network it is monitored for connectivity, disk, memory and CPU utilization – as well as hardware failures. Our engineers are alerted to potential issues before they become critical.
- Network
ASPHostPortal has architected its network like no other hosting company. Every facet of our network infrastructure scales to gigabit speeds with no single point of failure.
- Security
Network security and the security of your server are ASPHostPortal’s top priorities. Our security team is constantly monitoring the entire network for unusual or suspicious behavior so that when it is detected we can address the issue before our network or your server is affected.
- Support Services
Engineers staff our data center 24 hours a day, 7 days a week, 365 days a year to manage the network infrastructure and oversee top-of-the-line servers that host our clients’ critical sites and services.



ASP.NET 4.0 Hosting :: Auto Start Web Applications in ASP.NET 4.0

clock November 11, 2010 06:47 by author Jervis

Some web applications require large amount of initialization processing time before serving the first request. In some cases web applications may also need to load the large amount of data in first request.

In earlier versions we used write the custom code in Application_Load method in Global.asax file to handle above scenarios.

Auto Start Feature which addresses this scenario is available when ASP.NET 4.0 runs on IIS 7.5 on windows server 2008 R2.

The feature enables you to

- Starting up an application pool
- Initializing an ASP.NET application


Configuring the auto-start feature for application pool in IIS 7.5

You need to set the following configuration in applicationHost.config file.

<applicationPools>
    <add name="MyApplicationPool" startMode="AlwaysRunning"  />
</applicationPools>

If your application pool containing multiple applications, you can auto-start individual applications by setting the following configuration in applicationHost.config file.

<sites>
  <site name="MySite" id="1">
    <application path="/"
         preloadEnabled="true"
         preloadProvider="PrewarmMyCache" >
        <!--  Additional content -->
    </application>
  </site>
</sites>

When an individual application pool is recycled IIS 7.5 uses the information in applicationHost.config file to determine which applications need to be automatically started.

When you set auto-start feature for application then IIS 7.5 sends a request to ASP.NET 4.0 to start the application. In this state application temporarily does not accept HTTP requests. After the initialization process, the ASP.NET application is ready to process the requests.

Advantage Using IIS 7.5 and ASP.NET 4.0 we now have a well-defined approach for performing expensive application initialization before processing first HTML request.

Example: with this auto-start feature we can initialize an application and then signal the load balancing server that the application was initialized and ready to accept HTTP traffic.

Reasons why you must trust ASPHostPortal.com

Every provider will tell you how they treat their support, uptime, expertise, guarantees, etc., are. Take a close look. What they’re really offering you is nothing close to what ASPHostPortal does. You will be treated with respect and provided the courtesy and service you would expect from a world-class web hosting business.

You’ll have highly trained, skilled professional technical support people ready, willing, and wanting to help you 24 hours a day. Your web hosting account servers are monitored from three monitoring points, with two alert points, every minute, 24 hours a day, 7 days a week, 365 days a year. The followings are the list of other added- benefits you can find when hosting with us:

- DELL Hardware
Dell hardware is engineered to keep critical enterprise applications running around the clock with clustered solutions fully tested and certified by Dell and other leading operating system and application providers.
- Recovery Systems
Recovery becomes easy and seamless with our fully managed backup services. We monitor your server to ensure your data is properly backed up and recoverable so when the time comes, you can easily repair or recover your data.
- Control Panel
We provide one of the most comprehensive customer control panels available. Providing maximum control and ease of use, our Control Panel serves as the central management point for your ASPHostPortal account. You’ll use a flexible, powerful hosting control panel that will give you direct control over your web hosting account. Our control panel and systems configuration is fully automated and this means your settings are configured automatically and instantly.
- Excellent Expertise in Technology
The reason we can provide you with a great amount of power, flexibility, and simplicity at such a discounted price is due to incredible efficiencies within our business. We have not just been providing hosting for many clients for years, we have also been researching, developing, and innovating every aspect of our operations, systems, procedures, strategy, management, and teams. Our operations are based on a continual improvement program where we review thousands of systems, operational and management metrics in real-time, to fine-tune every aspect of our operation and activities. We continually train and retrain all people in our teams. We provide all people in our teams with the time, space, and inspiration to research, understand, and explore the Internet in search of greater knowledge. We do this while providing you with the best hosting services for the lowest possible price.
- Data Center
ASPHostPortal modular Tier-3 data center was specifically designed to be a world-class web hosting facility totally dedicated to uncompromised performance and security
- Monitoring Services
From the moment your server is connected to our network it is monitored for connectivity, disk, memory and CPU utilization – as well as hardware failures. Our engineers are alerted to potential issues before they become critical.
- Network
ASPHostPortal has architected its network like no other hosting company. Every facet of our network infrastructure scales to gigabit speeds with no single point of failure.
- Security
Network security and the security of your server are ASPHostPortal’s top priorities. Our security team is constantly monitoring the entire network for unusual or suspicious behavior so that when it is detected we can address the issue before our network or your server is affected.
- Support Services
Engineers staff our data center 24 hours a day, 7 days a week, 365 days a year to manage the network infrastructure and oversee top-of-the-line servers that host our clients’ critical sites and services.



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