.NET Framework 4.0 debuts today

DiscountASP.NET is happy to announce that we now support .NET Framework 4.0 on all of our Windows 2008/IIS 7 servers.

We know that our customers have come to expect to be able to utilize new technologies as soon as they are available, so we always strive to be the first host to offer the latest and greatest. Our close relationship with Microsoft and our labs program make it possible for us (and you!) to become familiar with new technologies before they are public, and allows us to hit the ground running with new releases, such as .NET Framework 4.0.

We have updated our Knowledge Base with several articles regarding .NET 4.0 application deployment with Visual Studio 2010, WCF RIA Services and more:

Also, check this very blog in the coming days for articles on such fresh-out-of-the-box goodies as web.config transformation, Visual Studio 2010’s Publish Database feature and more.

URL Rewrite 2.0 for IIS 7 is here

We recently upgraded the IIS 7 servers with version 2.0 of the URL rewrite module.

I have to be honest – generally speaking, SEO & URL rewriting is not a topic that I often (ever) think about. The reality is, no matter how you write your URLs, if your site only has a handful of visitors, the format of your URLs is not going to matter. Your time would be much better spent improving your site, making it more useful and popular. So why spend time and energy on such a topic when there is so much other stuff to do? I think most people share this opinion. But that’s what makes this new version so interesting to me.

Yes, this is indeed a major upgrade, and the feature list is lengthy. But what “The rest of us” will be happy to know is that Microsoft has included templates that make this process much easier. These are essentially tiny wizards that allow you to plug in a couple values and let the tool deal with the rest.

The first thing you need to do is get the IIS 7 Manager add-in to control the service.  When you connect to the server using IIS 7 Manager you will be greeted with a window asking if you would like to install the add-in (if you have the old module already, you will be asked to upgrade when you connect).

Now, let’s try a few things and see how easy this is. Let’s assume that you want to redirect requests for YourHostedDomainName.com to www.YourHostedDomainName.com

  • In IIS 7 Manager, navigate to the URL Rewrite section
  • Click Add Rule on the right hand side
  • Click the canonical domain name template
  • Enter your domain name, including the www

That’s it. Done.

Next, let’s work on making some user-friendly URLs. Let’s assume for a moment that we have an application that generates URLs in the following manner:

http://www.YourHostedDomainName.com/application/default.aspx?id=123

And we wanted to rewrite the URL as:

http://www.YourHostedDomainName.com/123

  • In IIS 7 Manager, navigate to the URL Rewrite section
  • Click Add Rule on the right side
  • Click User-Friendly URL

You will notice that you have an option for how you want the URL to be rewritten. The best part is that it is generating the regular expressions and corresponding inbound/outbound rules required to perform the task automatically.

Another cool feature is that by clicking the Create corresponding outbound rewrite rule check box, any links with an unfriendly URL within your pages will also be rewritten.

So for example, let’s assume you had a page with the following link:

<a href=”Test”>http://www.YourHostedDomainName.com/application/default.aspx?id=123″>Test Link</a>

This link would automatically be rewritten on the fly and served as:

http://www.YourHostedDomainName.com/123

These two scenarios are what we get asked about most commonly. You can see how easily URL Rewrite 2.0 addresses them. And we have not even scratched the surface. This release is extremely deep and can be used to perform a multitude of tasks. If you want to work with some of the more complex operations, I suggest you visit the learning section of the IIS site.

Some of the key points that stand out are:

Access to server variables and http headers. Server variables and HTTP headers provide additional information about current HTTP request. This information can be used to make rewriting decisions or to compose the output URL.

Various rule actions. Instead of rewriting a URL, a rule may perform other actions, such as issue an HTTP redirect, abort the request, or send a custom status code to HTTP client.

Failed Request Tracing support. IIS 7 Failed Request Tracing can be used to troubleshoot errors related to URL rewriting.

GUI tool for importing of mod_rewrite rules. URL rewrite module includes a GUI tool for converting rewrite rules from mod_rewrite format into an IIS format.

Michael Ossou
Technical Support

Model View Controller (MVC) 2.0

On March 11, 2010, the Microsoft ASP.NET team released Model View Controller (MVC) 2.0 RTM. You can download/install MVC 2.0 RTM with either:

The Web Platform Installer
or:
Direct download

MVC 2.0 contains a number of new features as well as bug fixes. For more details on the new features, please review the following articles:

http://weblogs.asp.net/scottgu/archive/2010/03/11/asp-net-mvc-2-released.aspx
http://haacked.com/archive/2010/03/11/aspnet-mvc2-released.aspx

After some intensive testing of MVC 2.0 on our system, I am pleased to announce that MVC 2.0 RTM is compatible with our hosting system. To learn about how to deploy MVC 2.0 applications to our hosting server, please review this KB article.

Frank Cheung
CTO

Excel integration without OWC or Interoperability

We have noticed an increase in interest from our customers in incorporating Microsoft Excel automation tasks into their ASP.NET applications. As OWC is a thing of the past, I’m going to concentrate on interoperability issues and a solution to the problem (more on that later).

For the purposes of these examples, all we are going to do is create a document.  Populating cells and doing other tasks, while easy enough, would detract from the focus of this post.

The scenario I outline below is rather common. Let’s start with the initial creation of the application on a developer’s box with Microsoft Office installed on it.


using Microsoft.Office.Interop.Excel;

protected void Button1_Click(object sender, EventArgs e)
{

Microsoft.Office.Interop.Excel.Application myApp = new Microsoft.Office.Interop.Excel.Application();

myApp.Visible = true;
Workbook myWorkBook = myApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
Worksheet myWorkSheet = (Worksheet)myWorkBook.Worksheets[1];

}

While this would indeed work on the developer’s machine, once uploaded to the server, an error such as the following would be thrown:

Could not load file or assembly 'Microsoft.Office.Interop.Excel, Version=12.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.

Naturally, they would then assume they needed to upload the Microsoft.Office.Interop.Excel.dll file to the bin directory. However this would lead to another error, similar to:

Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046}
failed due to the following error: 80040154.

If it runs on the developer’s machine, why doesn’t it run on the server?

First, some background. Interoperability is what allows .NET (the CLR specifically) to leverage unmanaged libraries. Essentially it works as a proxy. In this case, we are interested in programmatically accessing the functionality of the Excel COM object.


The application itself isn’t concerned with the COM object, only the interop assembly.  This is the reason for the first error. Upon uploading the interop to the bin directory, the application will at least then compile, but attempting to work with the interop will result in the second error.  This is because unlike the developer’s station, the COM object isn’t present on the server (Office cannot be installed on the servers – licensing, security, and performance issues prevent this).

Ok so what’s the solution? Well, as it turns out, there is a project called ExcelPackage that will allow us to work with Excel documents without having to worry about Office, Interops, OWC, or anything else! This is due to the use of XML file formats. The only downside being it won’t help you when working with ancient versions of Excel. So let’s get to it.

  • First, go get ExcelPackage
  • Next unzip it and place the .dll in your applications bin directory
  • Create an .xlsx document in Excel and put it in your applications root (for this sample). This is the template we are going to use to create our document from I’ve called mine Book1.xlsx
  • Create a reference in Visual Studio for the ExcelPackage.dll
  • Build your application and upload!

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
 {
FileInfo myTemplate = new FileInfo(@"e:\web\domain\htdocs\APP\book1.xlsx");
FileInfo myExcelFile = new FileInfo(@"e:\web\domain\htdocs\APP\NewXclFile.xlsx");

using (ExcelPackage xlPackage = new ExcelPackage(myExcelFile, myTemplate));

Response.Redirect(@”~/NewXclFile.xlsx”);

}
}

Michael Ossou

State of Silverlight: A Shared Windows Hosting Provider Perspective

As a shared Microsoft Windows hosting provider that offers hosting for Silverlight-powered web applications, the team at DiscountASP.NET was interested in understanding the market share and adoption of Silverlight. We conducted some research but we found that there was not much data on Silverlight adoption.

While we found some statistics on the numbers of PCs and browsers that can consume Silverlight and Flash experiences, we did not find any data on the adoption of Silverlight within web applications and web sites – those sites that are delivering the Silverlight and Flash experience.

Due to this lack of data and in order to provide the community with some new data points, our team at DiscountASP.NET decided to conduct our own research into Silverlight adoption among the web sites that we host.  As one of the largest ASP.NET web hosting providers with over 30,000 clients worldwide, DiscountASP.NET is uniquely positioned to help gain better knowledge on technology adoption with a rich customer sample size. In February 2010, we conducted a survey asking our customers about the technologies that they use to power their web sites and their interest level in upcoming new Microsoft technologies.

We present the results of our findings in the research paper below. Examining the data collected by different sample segmentation views, we discuss global technology adoption trends as well as the enthusiasm level of new technologies and their implications for future technology adoption.

Let us know what you think. Here is a link to the research paper:

State of Silverlight: A Shared Windows Hosting Provider Perspective:
Global Implications for Silverlight Adoption and Technology Adoption Strategy

Takeshi Eto
VP Marketing and Business Development

My site has been hacked!

Well, not really…

Unfortunately, over the past few months, we have seen a rise in the number of sites infected with malware. The most common question we get after such an event is, “How did my site get hacked?”  At face value, this seems like a perfectly reasonable conclusion. The reality of the matter is that the servers aren’t being “hacked.” I’m not proclaiming to the world that we are hack-proof. We do, however, spend a lot of time, energy, and resources (read: money!) on this front. In fact, in all of the security related issues our customers have had, never once has it been a case of a hacker “hacking our systems.”

In reality, 90% of the incidents are related to compromised developer machines. Essentially, evil software somehow makes its way on to a developer’s machine and captures the FTP login details. A few hours later, the FTP logs will show dozens of connections originating from all over the world accessing the site. The end result leads to a lot of work, potential embarrassment in front of a client, and angry site visitors.

People who work in the industry generally have pretty good habits. They don’t open attachments from strangers, surf the web on their development machines, or install non-essential software. They change their passwords regularly and don’t hand out credentials and access like after dinner mints. But it becomes easy to let our guard down. The reality is, we are also held to a higher standard. Explaining to a client that all you did was charge your phone or charge some batteries could still result in the loss of a client.

This a friendly reminder for us all to stay diligent, follow good practices, and make sure we do everything we can to keep our developer stations clean.

As for the other 10% of site compromises, they are usually related to a vulnerable application.  SQL injections, commercial/free applications that have not been patched or updated, and other application related oddities.

Michael Ossou
Technical Support

SSL Encrypted SQL Communication: SQL Hosting Security Enhancement

For Q1, we’ve been focusing on many enhancements to our SQL server hosting service. I’m happy to announce that we’ve added an extra level of security to our SQL hosting service with the introduction of SSL Encrypted SQL Connections.

With this security enhancement, DiscountASP.NET customers can use SQL Management Studio and use the “Encrypt Connection” option when connecting to their database. This is an option for SQL 2008 and SQL 2005 in both the US and UK hosting locations.

We hope that this becomes a standard for all hosts.

Here is a link to the press release.

Takeshi Eto
VP Marketing and Business Development

It’s not a blow off. Really. We still love you.

If you have ever had to contact DiscountASP.NET support, you may have noticed that there are certain issues that will result in a response asking you to check the forum for an answer. The first reaction of a lot of people when they receive a response like that is something along the lines of, “Hey, why are you blowing me off!” (often expressed in more colorful language). That reaction is understandable. For a lot of hosts that would be a blow off.

We don’t consider it to be a deflection though, because we take a lot of pride in the quality of our forum. You might have seen that quality yourself if you have searched Google for something related to .NET, SQL, DNS, etc., and the first links listed are threads in our forum! That tells you that we’re dealing with some technical and often unique stuff in there. The level of questions always amazes me, and the answers even more so. There are some really smart people posting in there, and you can benefit from their brainpower, research and mistakes very easily.

Forum regulars include many members of our staff, from tech support all the way up to the CTO. “Hey, wait a minute,” I hear some of you asking, “why didn’t tech support just answer my question in the helpdesk if they are only going to turn around and answer it in the forum?”

Good question.

Aristotle flips the switch that launches IIS7 while Cedric, Joe and some headless people observe in stunned, slack-jawed revirie and awe.

There are a couple of answers. First, the support staff cannot troubleshoot customer code or applications. They can’t alter files or otherwise make any changes to customer data. That rule is in place to protect both us and you. It is a thin line between troubleshooting and development work at times, and we cannot cross over into that territory.

But in the forum, if you can post relevant bits of code or configuration, you are likely to get some suggestions. If they don’t work, hey, everyone tries again, and eventually your problem is solved. It’s not a grand and official proclamation from THE COMPANY that doing A, B and C will fix your problem (though they do have some of those answers up their sleeves as well). In the forum, more than two people can join in, and that increases your odds of finding a successful resolution.

The second reason we might point you to the forum is because a helpdesk ticket benefits only one person, but a forum post can benefit hundreds of people. Of course we don’t take that concept so far that we send people to the forum for issues support can assist with. But for a lot of common issues, sending someone to the forum opens their eyes to the wealth of information there. And maybe the next time they have a question they will search the forum and find an answer much more quickly than they could have with a support ticket.

But again, all of this doesn’t mean that every support ticket ends with a trip to the forum. Not at all. We answer about 100,000 helpdesk tickets every year, as opposed to about 10,000 posts in our forum. So we answer a lot of questions in the helpdesk. But we like to think of the forum (and the Knowledge Base!) as an extension of the helpdesk.