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 :: How to Modify Custom Error 404 in ASP.NET

clock February 14, 2013 11:43 by author andy_yo

One of the improvements We wanted to make after deploying our website were to add useful error pages. You know more than the YSOD (yellow screen of death). One of the major issues for me was creating a useful and informative 404 page. We wanted the page to tell the user why they got there, offer suggestions about what page they may be looking for, and allow them to search the site. So We did the development work committed the changes and had the CI machine push to the server (in the case app harbor).

1.       <system.web>

2.           <compilationdebug=truetargetFramework=4.0 />

3.           <customErrorsmode=OndefaultRedirect=~/error>

4.               <errorstatusCode=404redirect=~/404 />

5.           </customErrors>

6.       </system.web>

But We were still seeing the generic IIS sever errors! We did some searching on the internet and found a helpful property of the response object.

1.       Response.TrySkipIisCustomErrors = true;

 

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

By default IIS will see an response with an error status code (400-500) and will automatically change the content of the response to its default error page. What this property does it tell IIS not to do that if there is already content in the body of the page. Well that was easy, right? So We made the change and pushed it to the server, and navigated to a page that didn't exist. Well the server still returned me the default 404 page, but on a 500 it would give me my custom error page. So what gives? Well here is the deal, the way routing works is that if ASP.NET cannot find a file that matches the requested URL the request is given back to IIS to handle. So in the case of a 404 ASP.NET can't find the file so its given back to IIS who uses the default static file handler to serve the request. This would be slightly different if the route had matched but then say somewhere in our code we set the status to 404. In this case it would already be in the ASP.NET pipeline and ASP.NET would server the custom 404 page.

There are two ways to solve this problem. First is the easiest which is to open up IIS Manger and go to the “Error Pages” settings under IIS and change the 404 page there to use your custom 404 page.

custom_error.png

This is fine if you can remote into the server or you're not running in the cloud where multiple instances can be started. So how then do you make that work? Well lucky that We are using IIS8 hosting, starting with IIS7 and later these settings can be added to your web.config file under the System.WebServer node.

1.       <system.webServer>

2.           <httpErrorserrorMode=Custom >

3.               <removestatusCode=404subStatusCode=-1/>

4.               <errorstatusCode=404path=/404responseMode=ExecuteURL />

5.           </httpErrors>

6.       </system.webServer>

So lets dig into what some of this code means and tell you about the tricky parts that you need to know. Before you can add a custom page you need to remove the entry for the status code as there can only be one entry per status code. The tricky bit here is knowing to set SubStatusCode to –1. This basically means all the possible sub statuses. If you like you could remove only the specific one you needed and set only the specific one. Also if you are playing around with the config you might find that there is a defaultPath attribute on the httpErrors node. This defines a “default” error page should an entry not be found in the list. The problem is that by default this is “locked” and cannot be set in an applications web.config and instead needs to be set at the machine level.  Once you add these settings to your config you should be able to see your custom error page when you navigate to a page that does not exist.



ASP.NET 4.5 Hosting - ASP.NET 4.5 Web Forms Key Features

clock January 23, 2013 12:50 by author andy_yo

Web Forms in 4.5 allows you to build dynamic web sites quickly and easily. Web Forms generates much cleaner code on client-side with Unobtrusive Validation in this version. You can also build data-centric applications easily with data-binding features.

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

Typical Web Form which contains more fields and validation controls can generate more code on client-side. When you run this typical form in browser then you can see the page size as below

 

The reason for this size is because client-side validation is enabled. If you change Unobtrusive validation mode in page load to web forms then you can see the difference.

Now re-compile your application and run the page the result is as shown below, Now page size is much smaller than before

Strongly typed Data Controls

Take a typical Search Form which shows the results in list view. Inside list view you have item template which is having multiple calls to the EVAL expression as shown below

The above method is the standard way of doing data-binding in web forms. You optimize the above using strongly typed data controls.

You can set the Item Type property of List View to the type that you actually data-binding to as shown below

Now you can member variables in place of Eval expressions, member variables are now typed and you will get an intellisense on item class.

Model Binding

You may be familiar with Model Binding in ASP.NET MVC, The typical code which you might write in web forms to bind the results in web forms as below

The above code talking to the data base by building a query which does a case insensitive search then it coverts into list binds the results to list view. Let us re-write the above code using Model-Binding

Now there is no page load and click-handler, The above code is not directly interacting with the page. You can populate the formTerm and qsTerm variables using attributes Control and QueryString in model-binding.

The return result of GetResults method is IQueryable. Because the result is of type IQueryable the control has the ability to modify this before it is rendering it to the page. You can use this in sorting and paging. You can specify the same in markup.

Advantage of using Model Binding As the code is not directly interacting with the page, you can fairly easily unit test the method or even move it to the completely different class.

Support for OpenID in OAuth Logins

The AuthConfig.cs file is standard in all new projects that created in ASP.NET 4.5 in Visual Studio 2012. You can see there are number of external services code is commented out and it is ready to use by putting your custom application credentials.

Now you can use external services to login to the application.

These are the features which you can try out in Visual Studio 2012.



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 MVC 4 Hosting - Fixing ASP.NET MVC 4 Web API 404

clock January 16, 2013 08:39 by author andy_yo

For a Web Service providing some REST-style URIs to access the data, I decided to use the ASP.NET MVC 4 Web API. Once developed, tested and deployed I experienced a mysterious 404 on my production server.

The Web API started originally as WCF Web API at CodePlex and is finally fully integrated within the latest .NET framework:

“ASP.NET Web API represents the joint efforts of the WCF and ASP.NET teams to create an integrated web API framework. You can get the bits and find articles, tutorials, samples and videos on the new ASP.NET Web API home page. All you have to do is to..”

The tutorials and examples for the ASP.NET Web API are overall easy to understand and you probably get access to the technology very quickly. After I set up my first Web API, which worked absolutely perfect on Windows 8, developed using Visual Studio 2012 and tested with the IIS Express, I was not able to get the bits executed on the deployment server. It’s a Windows Server 2008 R2, IIS 7.5 and a whole bunch of stuff installed using the Web Platform Installer.

Make sure the .NET Framework is installed. Probably you missed to install the 4.5 framework on the deployment server. As IIS is set up already, once again it is necessary to register ASP.NET for the latest framework by opening your command prompt and type:

C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis.exe -i

Even now, I got the 404. Eventually, I got the tip to check out how the routing of extensionless URLs work in ASP.NET. By adding

<system.webServer>

<modules runAllManagedModulesForAllRequests="true" />

...

</system.webServer>

to the web.config file of my Web API  the routing seems to work fine now.

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



ASP.NET 4.5 Hosting - ASP.NET Web Pages - Adding Razor Code

clock January 16, 2013 06:18 by author andy_yo

In this article we will learn how to use Razor markup with C# and Visual Basic code


What is Razor?

  • Razor is a markup syntax for adding server-based code to web pages
  • Razor has the power of traditional ASP.NET markup, but is easier to learn, and easier to use
  • Razor is a server side markup syntax much like ASP and PHP
  • Razor supports C# and Visual Basic programming languages

Adding Razor Code

<!DOCTYPE html>

<html lang="en">
<head>
<meta charset="utf-8" />
<title>Web Pages Demo</title>
</head>
<body>
<h1>Hello Web Pages</h1>
</body>
</html>

Now add some Razor code to the example:

Example

<!DOCTYPE html>

<html lang="en">
<head>
<meta charset="utf-8" />
<title>Web Pages Demo</title>
</head>
<body>
<h1>Hello Web Pages</h1>
<p>The time is @DateTime.Now</p>
</body>
</html>

The page contains ordinary HTML markup, with one addition: the @ marked Razor code.

The Razor code does all the work of determining the current time on the server and display it. (You can specify formatting options, or just display the default)


Main Razor Syntax Rules for C#

  • Razor code blocks are enclosed in @{ ... }
  • Inline expressions (variables and functions) start with @
  • Code statements end with semicolon
  • Variables are declared with the var keyword
  • Strings are enclosed with quotation marks
  • C# code is case sensitive
  • C# files have the extension .cshtml

C# Example

<!-- Single statement block -->
@{ var myMessage = "Hello World"; }

<!-- Inline expression or variable -->
<p>The value of myMessage is: @myMessage</p>

<!-- Multi-statement block -->
@{
var greeting = "Welcome to our site!";
var weekDay = DateTime.Now.DayOfWeek;
var greetingMessage = greeting + " Today is: " + weekDay;
}
<p>The greeting is: @greetingMessage</p>


Main Razor Syntax Rules for VB

  • Razor code blocks are enclosed in @Code ... End Code
  • Inline expressions (variables and functions) start with @
  • Variables are declared with the Dim keyword
  • Strings are enclosed with quotation marks
  • VB code is not case sensitive
  • VB files have the extension .vbhtml

Example

<!-- Single statement block  -->
@Code dim myMessage = "Hello World" End Code

<!-- Inline expression or variable -->
<p>The value of myMessage is: @myMessage</p>

<!-- Multi-statement block -->
@Code
dim greeting = "Welcome to our site!"
dim weekDay = DateTime.Now.DayOfWeek
dim greetingMessage = greeting & " Today is: " & weekDay
End Code

<p>The greeting is: @greetingMessage</p>

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



ASP.NET 4.5 Hosting - ASPHostPortal :: New HTML 5 in ASP.NET 4.5

clock November 29, 2011 09:44 by author Jervis

Microsoft has released developer previews for Visual Studio 2011 and .Net framework 4.5. There are lots of new features available in the developer preview. One of the most interested things for web developers is the support introduced for new HTML 5 form controls.

The following are the list of new controls available in HTML 5

·         email

·         url

·         number

·         range

·         Date pickers (date, month, week, time, datetime, datetime-local)

·         search

·         color

I have created a project in Visual Studio 2011 developer preview, and created a page named “controls.aspx”. In the page I placed on Text box control from the toolbox.



Now select the control and go to the properties pane, look at the TextMode attribute.



Now you can see more options are added here than prior versions of ASP.Net. I just selected Email as TextMode. I added one button to submit my page. The screen shot of the page in Visual Studio 2011 designer is as follows



See the corresponding markup


<form id="form1" runat="server">
    <div>
        Enter your email:
        <asp:TextBox ID="TextBox1" runat="server" TextMode="Email"></asp:TextBox
    </div>
    <asp:Button ID="Button1" runat="server" Text="Submit" />
</form>


Now let me run this page, IE 9 do not have the support for new form fields. I browsed the page using Firefox and the page appears as below.



From the source of the rendered page, I saw the below markup for my email textbox

<input name="TextBox1" type="email" id="TextBox1" />

Try to enter an invalid email and you will see the browser will ask you to enter a valid one by default.



When rendered in non-supported browsers, these fields are behaving just as normal text boxes. So make sure you are using validation controls with these fields.

See the browser support compatability matrix with these controls with various browser vendors.



ASP.Net 4.5 introduced the support for these new form controls. You can build interactive forms using the newly added controls, keeping in mind that you need to validate the data for non-supported browsers.

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.5 Hosting - ASPHostPortal :: New Features in ASP.NET 4.5

clock October 20, 2011 07:24 by author Jervis

Another major release in .NET Framework, .NET 4.5 which allows the developers to use Windows 8 technologies and windows runtime directly from .NET 4.5. It makes easy and natural to write Metro style applications using C# and VB. .NET 4.5 makes your applications run faster eg: Faster ASP.NET startup. .NET 4.5 gives  you easy access to your data with entity framework code first approach and recent SQL Server features. This post discuss these features in detail.

You can download the .NET FW  4.5 Developer preview from
here.

ASP.NET 4.5 with ASPHostPortal Coming Soon



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