ASPHostDirectory Cheap .NET 4 Hosting

Blog about .NET Hosting and all its latest technology

ASPHostDirectory.com .NET 4 Hosting :: Using Dynamic Objects in Silverlight 4

clock July 15, 2010 06:32 by author Darwin

This article gives brief explanation about Silverlight 4. If you’re looking for Silverlight 4 hosting, you can get the professional hosting at ASPHostDirectory. Only with $ 3.99/month to get SL 4 hosting. What are you waiting for?

One of the cool new features in Silverlight 4 is the ability to data bind to indexed properties. This means that even if you don’t know at design time what properties you data object has you can still data bind to them.

The syntax is very similar to a normal data binding, only in this case you need to use the [key] syntax instead. For example in example below the FirstName is a regular property while the LastName below is an indexed property.

<StackPanel Name="LayoutRoot"> 
    <StackPanel Orientation="Horizontal" Margin="1"> 
        <TextBlock Text="FirstName" Width="150"></TextBlock> 
        <TextBox Text="{Binding FirstName, Mode=TwoWay}" Width="500"></TextBox> 
    </StackPanel> 
    <StackPanel Orientation="Horizontal" Margin="1"> 
        <TextBlock Text="LastName" Width="150"></TextBlock> 
        <TextBox Text="{Binding [LastName], Mode=TwoWay}" Width="500"></TextBox> 
    </StackPanel>
</StackPanel>

Creating the class to data bind to is simple. All you need to do is add a property with the following syntax:

public object this[string key] 
    { get; set; }

In this example we are using a Peron class with a regular FirstName property and all others are dong using indexed properties. The complete class, including INotifyPropertyChanged looks like this:

public class Person : INotifyPropertyChanged

    public Person() 
   
        PropertyChanged = (s, e) => { };

        FirstName = "Maurice"; 
        this["LastName"] = "de Beijer";
        this["BabyName"] = "Kai"; 
    }

    private Dictionary<string, object> _data = new Dictionary<string, object>(); 
    public object this[string key] 
   
        get 
       
            if (!_data.ContainsKey(key)) 
                _data[key] = null;

            return _data[key]; 
       
        set 
       
            _data[key] = value; 
            PropertyChanged(this, new PropertyChangedEventArgs("")); 
       
    }

    public IEnumerable<string> Keys 
    {
        get 
        {
            return _data.Keys; 
        }
    }

    private string _firstName; 
    public string FirstName
   
        get
       
            return _firstName;
       
        set 
       
            _firstName = value; 
            PropertyChanged(this, new PropertyChangedEventArgs("FirstName")); 
       
    }

    public event PropertyChangedEventHandler PropertyChanged;
}

While not having to know the objects structure at design time is nice but in the XAML above we still hard coded the data bindings so that doesn’t buy us much yet. So fully utilize this we need to dynamically generate the UI as well. Fortunately that is quite easy to do with the following code:

void MainPage_Loaded(object sender, RoutedEventArgs e)

    var person = new Person(); 
    DataContext = person; 
    foreach (var item in person.Keys) 
   
        var lbl = new TextBlock(); 
        lbl.Text = item; 
        lbl.Width = 150;

        var txt = new TextBox(); 
        var binding = new Binding("[" + item + "]"); 
        binding.Mode = BindingMode.TwoWay; 
        txt.SetBinding(TextBox.TextProperty, binding); 
        txt.Width = 500;

        var line = new StackPanel(); 
        line.Orientation = Orientation.Horizontal; 
        line.Children.Add(lbl); 
        line.Children.Add(txt); 
        line.Margin = new Thickness(1); 
        LayoutRoot.Children.Add(line); 
    }
}

And now you can see the result. Try it!
Happy Programming!

What is so SPECIAL on ASPHostDirectory.com Silverlight Hosting?

We know that finding a cheap, reliable web host is not a simple task so we’ve put all the information you need in one place to help you make your decision. At ASPHostDirectory, we pride ourselves in our commitment to our customers and want to make sure they have all the details they need before making that big decision.

We will work tirelessly to provide a refreshing and friendly level of customer service. We believe in creativity, innovation, and a competitive spirit in all that we do. We are sound, honest company who feels that business is more than just the bottom line. We consider every business opportunity a chance to engage and interact with our customers and our community. Neither our clients nor our employees are a commodity. They are part of our family.

The followings are the top 10 reasons you should trust your online business and hosting needs to us:

- FREE domain for Life - ASPHostDirectory gives you your own free domain name for life with our Professional Hosting Plan and 3 free domains with any of Reseller Hosting Plan! There’s no need to panic about renewing your domain as ASPHostDirectory will automatically do this for you to ensure you never lose the all important identity of your site
- 99,9% Uptime Guarantee - ASPHostDirectory promises it’s customers 99.9% network uptime! We are so concerned about uptime that we set up our own company to monitor people’s uptime for them called ASPHostDirectory Uptime
- 24/7-based Support - We never fall asleep and we run a service that is opening 24/7 a year. Even everyone is on holiday during Easter or Christmast/New Year, we are always behind our desk serving our customers
- Customer Tailored Support - if you compare our hosting plans to others you will see that we are offering a much better deal in every aspect; performance, disk quotas, bandwidth allocation, databases, security, control panel features, e-mail services, real-time stats, and service
- Money Back Guarantee - ASPHostDirectory offers a ‘no questions asked’ money back guarantee with all our plans for any cancellations made within the first 30 days of ordering. Our cancellation policy is very simple - if you cancel your account within 30 days of first signing up we will provide you with a full refund
- Experts in Silverlight Hosting
- Given the scale of our environment, we have recruited and developed some of the best talent in the hosting technology that you are using. Our team is strong because of the experience and talents of the individuals who make up ASPHostDirectory
- Daily Backup Service - We realise that your website is very important to your business and hence, we never ever forget to create a daily backup. Your database and website are backup every night into a permanent remote tape drive to ensure that they are always safe and secure. The backup is always ready and available anytime you need it
- Easy Site Administration - With our powerful control panel, you can always administer most of your site features easily without even needing to contact for our Support Team. Additionally, you can also install more than 100 FREE applications directly via our Control  Panel in 1 minute!

Happy Hosting!



ASPHostDirectory.com .NET 4 Hosting :: Using SSRS 2008 x64 with MYSQL

clock July 15, 2010 06:24 by author Darwin

Are you looking for SSRS 2008 hosting? Find the best, quality, and cheap SSRS 2008 hosting at ASPHostDirectory. Only with $ 3.99/month  to get SSRS 2008 hosting. The article below describes brief information about how to using SSRS 2008 x64 with MYSQL.

Here we go:

1. Download and Execute onto the server that is hosting your Report Manager
mysql-connector-odbc-5.1.6-winx64.msi.

2. Once that is installed then Confirm the driver is being recognized:
A.Go to Start/Administrative Tools/Data Sources (ODBC)
B. Select the Driver tab and validate it is in the list.

3. Setting up the System DSN for the MYSQL Connection will allow you to create a MYSQL data source in Report Manager.
A.Go to Start/Administrative Tools/Data Sources (ODBC)
B. Select System DSN tab
C. Press Add
D. Select the MySQL Driver in the list and press Finish
E. Fill in the goodies and Test

4.Log onto your Report Manager
A.Create a new Data Source
B. Select ODBC for Data Source Type.
C. In the Connection String box type DSN=(Your DSN Name you gave the mysql connection)
D. Select Credentials stored securely in the report server, pass your user name and password for the mysql connection.

You should now be able to you this data source to post reports using the mysql database.

What is so SPECIAL on ASPHostDirectory.com Reporting Service Hosting?

We know that finding a cheap, reliable web host is not a simple task so we’ve put all the information you need in one place to help you make your decision. At ASPHostDirectory, we pride ourselves in our commitment to our customers and want to make sure they have all the details they need before making that big decision.

We will work tirelessly to provide a refreshing and friendly level of customer service. We believe in creativity, innovation, and a competitive spirit in all that we do. We are sound, honest company who feels that business is more than just the bottom line. We consider every business opportunity a chance to engage and interact with our customers and our community. Neither our clients nor our employees are a commodity. They are part of our family.

The followings are the top 10 reasons you should trust your online business and hosting needs to us:

- FREE domain for Life - ASPHostDirectory gives you your own free domain name for life with our Professional Hosting Plan and 3 free domains with any of Reseller Hosting Plan! There’s no need to panic about renewing your domain as ASPHostDirectory will automatically do this for you to ensure you never lose the all important identity of your site
- 99,9% Uptime Guarantee - ASPHostDirectory promises it’s customers 99.9% network uptime! We are so concerned about uptime that we set up our own company to monitor people’s uptime for them called ASPHostDirectory Uptime
- 24/7-based Support - We never fall asleep and we run a service that is opening 24/7 a year. Even everyone is on holiday during Easter or Christmast/New Year, we are always behind our desk serving our customers
- Customer Tailored Support - if you compare our hosting plans to others you will see that we are offering a much better deal in every aspect; performance, disk quotas, bandwidth allocation, databases, security, control panel features, e-mail services, real-time stats, and service
- Money Back Guarantee - ASPHostDirectory offers a ‘no questions asked’ money back guarantee with all our plans for any cancellations made within the first 30 days of ordering. Our cancellation policy is very simple - if you cancel your account within 30 days of first signing up we will provide you with a full refund
- Experts in Reporting Service Hosting
- Given the scale of our environment, we have recruited and developed some of the best talent in the hosting technology that you are using. Our team is strong because of the experience and talents of the individuals who make up ASPHostDirectory
- Daily Backup Service - We realise that your website is very important to your business and hence, we never ever forget to create a daily backup. Your database and website are backup every night into a permanent remote tape drive to ensure that they are always safe and secure. The backup is always ready and available anytime you need it
- Easy Site Administration - With our powerful control panel, you can always administer most of your site features easily without even needing to contact for our Support Team. Additionally, you can also install more than 100 FREE applications directly via our Control  Panel in 1 minute!

Happy Hosting!

 



ASPHostDirectory.com .NET 4 Hosting :: Information Architecture - Why SharePoint 2007 Needs It

clock July 14, 2010 11:38 by author Darwin

SharePoint as a defining technology

SharePoint is a classic case of a technology defining our information environment. For many organizations, its deployment changes the way users interact and manage their information environment. Only a few technologies have been able to do this since IT became commonplace in the 1980s (Microsoft, of course, has done this before with the PC). 

SharePoint's raison d'être is its integration of different functional applications within one system, and the homogeneity of its approach to managing content.  These are the features, we believe, that re-define the way many people think about information. There are many systems that do specific things much better than SharePoint, but none of them do it in such an integrated and uniform fashion. In addition, because SharePoint is a consumer technology (rather than an expert technology), it solves lowest common denominator problems, rather than specialised problems. Thus, the integration and homogeneity is at the superficial user experience level, but alas not at the deeper information architecture level.

SharePoint needs an Information Architecture

Our direct and indirect experience of many SharePoint implementations has reinforced, to the point of absurdity, the belief that all information systems (the clue is in their description...) need an information architecture. We don't need to get carried away here - rigorously crafted, comprehensively detailed information architectures such as the traditional fileplan in a pure EDRMS, are a thing of the past. Similarly the newspeak of Web 2.0, folksonomies, etc. are also not appropriate because of their inherent informality and lack of rigour. The reality of developing useful, practical information architectures is actually somewhere in between - a third way.

This pragmatic view is alas much less interesting to feature writers and trend-followers, but it is much more important to users and cheque-signers!  The weakness of the two extremes - design everything upfront and try not to change it, or just get on with it and fix it up along the way - have never been more sharply brought into focus than when developing SharePoint systems.

Too little Information Architecture

We'd guess that 75% of all SharePoint implementations are done without any information architecture whatsoever. This is typically because they are just deployed by the IT department pretty much in isolation from the business's information management requirements, usually because IT want to see what SharePoint can do (it's a new toy and it will look great on their CVs), or the head of IT thinks it will quickly solve some business problems (it might - eventually). 

Often, organisations will install it because they got it for free with their Microsoft enterprise software license, so surely it must be cost effective to stick it in and use it? Without an information architecture, in all but the smallest organisation, this will at best result in a nicer looking way of doing what you already do, or at worst, produce even more information silos, less control and less usability. For example, simply replacing folders on your network with SharePoint Team sites for anybody who wants them, reproduces the chaos and lack of findabiity that you already have.

Too much Information Architecture

Of course, this situation is significantly rarer, but it does happen. Some organisations are so risk averse, that they architect too much, designing and planning for a perfection that can never be delivered, and is out of date from the second day of the project.

We have observed however, a growing trend for treating SharePoint in this way. We think the reasons for this are clear: there are now sufficient horror stories in the public domain that the late adopters see a highly prescriptive design as the solution. But too much can be as counter-productive as too little: we have merely changed the project's cost profile from low-then-high (too little IA - all the work is managing the deployment), to high-then-low (too much IA - all the work is designing the deployment).

Getting it right

The most efficient, cost-effective and user-friendly approach to designing the SharePoint environment should tread a middle path.  One needs to do enough information architecture to cover those things that need to be specified up front to define a framework upon which SharePoint can be built, without being too detailed or inflexible. This is the art of a good information architect. In SharePoint, however, there are other (frequently hidden) challenges to overcome.

Much as we'd like to design thinking only about corporate strategy, user needs and the nature of the content, information architecture can never be truly technology neutral. This is never more the case than with SharePoint and there are some fundamental reasons why:

- Extent. With the exception of the big ERP systems (SAP, Oracle etc.), there are few off-the-shelf systems with such a wide and comprehensive set of functions.

- Integration. As has already been mentioned, SharePoint is very richly integrated with all its component parts, and even with non-Microsoft technology. The sum of the parts is much more complicated than the individual parts.

- Quirks. There are many of these! This is partly a result of the two points above, but also because the product had to ship. There are many perplexing omissions in the product but, for the SharePoint product managers, that's better than taking another year to fix them.

- Inconsistency. For the information architect, this is the big one. Again, because of all the points above, there are far too many inconsistencies - in the underlying information structures, in the user access model, in the navigation systems, in the administrative and configuration interfaces, in the application of functionality across the environment, and many more areas.

A Pragmatic Approach

Despite our criticisms, SharePoint can be delivered to good effect and experience has taught me a set of useful steps when approaching design and implementation.  Many of these steps can be applied to any complex information system, but are especially apposite for SharePoint:

- Get some basic technology infrastructure set up as early as possible, but expect it to change once the business requirements are clearer. It's one less thing to worry about and, crucially, allows all the next steps to happen.

- Prototype first. Try some things out, see what it can do, experiment. This can take a while if you are new to SharePoint, so get experts to show you what SharePoint can do if you need a helping hand to start. Plan to throw the prototype away. Do not be tempted or forced to make it live. A prototype is not the same as the real thing. Use the experiences from the prototype, not the prototype itself.

- Define senior management expectations. What are they expecting the implementation to deliver, in particular what business benefits are they looking for, and how will you measure whether they've been delivered?

- Involve users as soon as possible.  It builds buy-in, increases their understanding and gives crucial feedback into what they want and how they want it. Agile, user-centred methodologies work well with SharePoint - use them.

- Don't over-customise. This is the step that I've seen most organisations get wrong. There are many ways to customise SharePoint. Some are very easy, some are very hard. Don't do the hard ones (yet). You may want that button specific to be pink, but is it really essential and are you prepared to spend development days and ongoing management to get it?

- SharePoint is for life, not just Christmas. SharePoint going live is not the end of the work. It is a complex system that is likely to sit at the heart of your organisation. It will need ongoing technology, business and information management to avoid falling into disrepair, let alone extending and improving. Look to how many people run your email, intranet and Web site - SharePoint could be as complex and important as all these systems put together.

SharePoint is here to stay

There are good and bad features in SharePoint, just as there good and bad ways to implement it. However, too little information architecture will not support sharing and findability, too much will incur unnecessary costs and time. SharePoint is not going away - we're going to have to get used to it. For the next decade, it will be as important to users as the Office suite is today. Microsoft will continue to extend and improve it, IT departments will continue to install it but, hopefully, information architects will get the best from it.

 



ASPHostDirectory.com .NET 4 Hosting :: ASP.NET MVC 2 Render Template to String

clock July 14, 2010 11:08 by author Darwin

This topic contains information about key features and improvements in the ASP.NET MVC routing. This topic doesn’t provide comprehensive information about all new features and is subject to change. So, if you seek more information about ASP.NET MVC, you can choose ASPHostDirectory as alternatives. You’ll get the best service at an affordable price. Only with @ 3.99/month, you can directly get the services you want. So, what are you waiting for? Try it!!

In one of the projects that we are currently working on we have a lot of different emails we want to send out to users and we would like to build those emails from templates. Our goal was the leverage the existing ASP.NET view engine for this, but that turned out to be a lot more complicated than we had anticipated.


It turns out that because of issues with the core Page class, the WebFormViewEngine always renders directly to the Response. You can get around this by creating a fake HttpContext, but that seems like a really ugly hack. After some more searching we found some information on another method that involves getting a partial view as a standard WebForms Control and rendering it directly to a string.


We had to make a few tweaks to the code given in the above article to get the ViewData to populate properly. Here is what we came up with:


using System.IO;

using System.Text;

using System.Web.Mvc;

using System.Web.UI;


namespace MyProject.ClassLibrary.Utilities

{

    public class Template

    {

        /// <summary>

        /// Render a Partial View (MVC User Control, .ascx) to a string using the given ViewData.

        /// </summary>

        /// <param name="controlName"></param>

        /// <param name="viewData"></param>

        /// <returns></returns>

        public static string RenderPartialToString(string controlName, object viewData)

        {

            ViewDataDictionary vd = new ViewDataDictionary(viewData);

            ViewPage vp = new ViewPage { ViewData = vd };

            Control control = vp.LoadControl(controlName);


            vp.Controls.Add(control);


            StringBuilder sb = new StringBuilder();

            using (StringWriter sw = new StringWriter(sb))

            {

                using (HtmlTextWriter tw = new HtmlTextWriter(sw))

                {

                    vp.RenderControl(tw);

                }

            }


            return sb.ToString();

        }

    }

}

You can now create a new template by adding a MVC 2 View User Control to your project (it should have the extension .ascx). The viewData object that you passed in is accessible through the ViewData.Model.

Here is a very simple example template:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>

This is a <em>simple</em> test email.

ViewData["test"] = <%: ((Dictionary<string, string>)ViewData.Model)["test"] %>


And you would render the template using:

Dictionary<string, string> viewData = new Dictionary<string, string>();

viewData["test"] = "This is a simple test string";

string output = MyProject.ClassLibrary.Utilities.Template.RenderPartialToString("~/Emails/TestEmail.ascx", viewData);

Ideally we should have been able to use the default MVC view engine to take care of this, but for now this method works well.

What is so SPECIAL on ASPHostDirectory.com .NET MVC Hosting?

We know that finding a cheap, reliable web host is not a simple task so we’ve put all the information you need in one place to help you make your decision. At ASPHostDirectory, we pride ourselves in our commitment to our customers and want to make sure they have all the details they need before making that big decision.

We will work tirelessly to provide a refreshing and friendly level of customer service. We believe in creativity, innovation, and a competitive spirit in all that we do. We are sound, honest company who feels that business is more than just the bottom line. We consider every business opportunity a chance to engage and interact with our customers and our community. Neither our clients nor our employees are a commodity. They are part of our family.

The followings are the top 10 reasons you should trust your online business and hosting needs to us:

- FREE domain for Life - ASPHostDirectory gives you your own free domain name for life with our Professional Hosting Plan and 3 free domains with any of Reseller Hosting Plan! There’s no need to panic about renewing your domain as ASPHostDirectory will automatically do this for you to ensure you never lose the all important identity of your site
- 99,9% Uptime Guarantee - ASPHostDirectory promises it’s customers 99.9% network uptime! We are so concerned about uptime that we set up our own company to monitor people’s uptime for them called ASPHostDirectory Uptime
- 24/7-based Support - We never fall asleep and we run a service that is opening 24/7 a year. Even everyone is on holiday during Easter or Christmast/New Year, we are always behind our desk serving our customers
- Customer Tailored Support - if you compare our hosting plans to others you will see that we are offering a much better deal in every aspect; performance, disk quotas, bandwidth allocation, databases, security, control panel features, e-mail services, real-time stats, and service
- Money Back Guarantee - ASPHostDirectory offers a ‘no questions asked’ money back guarantee with all our plans for any cancellations made within the first 30 days of ordering. Our cancellation policy is very simple - if you cancel your account within 30 days of first signing up we will provide you with a full refund
- Experts in .Net MVC Hosting
- Given the scale of our environment, we have recruited and developed some of the best talent in the hosting technology that you are using. Our team is strong because of the experience and talents of the individuals who make up ASPHostDirectory
- Daily Backup Service - We realise that your website is very important to your business and hence, we never ever forget to create a daily backup. Your database and website are backup every night into a permanent remote tape drive to ensure that they are always safe and secure. The backup is always ready and available anytime you need it
- Easy Site Administration - With our powerful control panel, you can always administer most of your site features easily without even needing to contact for our Support Team. Additionally, you can also install more than 100 FREE applications directly via our Control  Panel in 1 minute!

Happy Hosting!

 



ASPHostDirectory.com .NET 4 Hosting :: How to configure Reporting Services 2008 in SharePoint 2010

clock July 13, 2010 07:58 by author Darwin

If you have a SharePoint 2010 site and you navigate to site settings and try to click on "Managed Services Schedule" you will get this error:Unsupported Reporting Services Functionality

This is because your SharePoint configuration is not configured with Reporting services server.

To fix that, follow below steps:

1) Login to the Reporting Services server and make sure that the service is up and running, and double check that the reporting server is working:

a) Open SQL Reporting configuration manager
b) Select Report Manager Url.
c) click on the url to make sure it is working.
For example: http://SERVERNAME/Reports/

2) Open SharePoint Central administration:

a) Select General Application Settings.
b) Select Reporting Services Integration.
c) Set the report server url.
d) Select authentication mode, Windows if the reports show personalized data.
OR select the trusted account that will be used for impersonation.
e) Click on Ok, You will get a successful page.
f) You might get the following error:
"Failed to establish connection with report server. Verify the server URL is correct or review ULS logs for more information. Product area: SQL Server Reporting Services, Category: Configuration Pages"

This means that the SSRS is not configured to run with SharePoint Integrated Mode, to change it,read below article "Overview of Configuration Steps on a Report Server":
http://technet.microsoft.com/en-us/library/bb326356.aspx

3) Go to your sharepoint site settings and enable Report Integration feature on site collection features.

4) Go to your site and add reporting services webpart in your page and configure it to your report.

Note: It is recommended to have a library that has all your reports in one place and all SQL Reporting services webparts are connecting to this library.

Conclusion

If you looking for SSRS 2008 hosting, entrust your site to ASPHostDirectory. You’ll get the best service with an affordable price. We guarantee that!!

What is so SPECIAL on ASPHostDirectory.com Reporting Service Hosting?

We know that finding a cheap, reliable web host is not a simple task so we’ve put all the information you need in one place to help you make your decision. At ASPHostDirectory, we pride ourselves in our commitment to our customers and want to make sure they have all the details they need before making that big decision.

We will work tirelessly to provide a refreshing and friendly level of customer service. We believe in creativity, innovation, and a competitive spirit in all that we do. We are sound, honest company who feels that business is more than just the bottom line. We consider every business opportunity a chance to engage and interact with our customers and our community. Neither our clients nor our employees are a commodity. They are part of our family.

The followings are the top 10 reasons you should trust your online business and hosting needs to us:

- FREE domain for Life - ASPHostDirectory gives you your own free domain name for life with our Professional Hosting Plan and 3 free domains with any of Reseller Hosting Plan! There’s no need to panic about renewing your domain as ASPHostDirectory will automatically do this for you to ensure you never lose the all important identity of your site
- 99,9% Uptime Guarantee - ASPHostDirectory promises it’s customers 99.9% network uptime! We are so concerned about uptime that we set up our own company to monitor people’s uptime for them called ASPHostDirectory Uptime
- 24/7-based Support - We never fall asleep and we run a service that is opening 24/7 a year. Even everyone is on holiday during Easter or Christmast/New Year, we are always behind our desk serving our customers
- Customer Tailored Support - if you compare our hosting plans to others you will see that we are offering a much better deal in every aspect; performance, disk quotas, bandwidth allocation, databases, security, control panel features, e-mail services, real-time stats, and service
- Money Back Guarantee - ASPHostDirectory offers a ‘no questions asked’ money back guarantee with all our plans for any cancellations made within the first 30 days of ordering. Our cancellation policy is very simple - if you cancel your account within 30 days of first signing up we will provide you with a full refund
- Experts in Reporting Service Hosting
- Given the scale of our environment, we have recruited and developed some of the best talent in the hosting technology that you are using. Our team is strong because of the experience and talents of the individuals who make up ASPHostDirectory
- Daily Backup Service - We realise that your website is very important to your business and hence, we never ever forget to create a daily backup. Your database and website are backup every night into a permanent remote tape drive to ensure that they are always safe and secure. The backup is always ready and available anytime you need it
- Easy Site Administration - With our powerful control panel, you can always administer most of your site features easily without even needing to contact for our Support Team. Additionally, you can also install more than 100 FREE applications directly via our Control  Panel in 1 minute!

Happy Hosting!

 



ASPHostDirectory.com .NET 4 Hosting :: Create a Database using Model-First Development

clock July 13, 2010 05:17 by author Darwin

Creating a Database using Model-First Development

Step 1: Create a new solution


1. Launch Visual Studio 2010 Beta 2.

2. Click the New Project link on the Start Page.  The New Project dialog box should appear.

3. Click on the Visual C# node from the tree view of installed templates.
4. Select Empty ASP.NET Web Application from the list of templates.
5. Enter OrderSystem for the project name and click the OK button.

Visual Studio will create a solution file in the folder you specified and also create a sub folder that contains the web site's project file and config files.

Step 2: Create an ADO.NET Entity Data Model

The next step is to create the ADO.NET Entity Data Model.  For this application we'll model the concept of users and addresses.  A user can have more that one address so we'll build an entity data model that models this relationship.

1. Right click on the OrderSystem project in the Solution Explorer and select Add à New Item…
2. Click the Data node under the Visual C# node in the Installed Templates tree.
3. Select the ADO.NET Entity Data Model template.
4. Change the name to OrderDB.edmx and click the Add button.
5. Visual Studio will display the Entity Data Model Wizard.  This is where you can decide to build the model from an existing database or create the model first and then build the database.
6. Choose Empty model from the wizard and click the Finish button.

Step 3: Create the Entities and Associations

The next step is to model the user and user's addresses relationship. Let's first create the user entity.

1. Right click on the Entity Data Model Designer and select AddàEntity… from the pop-up menu.
2. The Add Entity dialog box should appear.  Enter UserAccount for the Entity name.  Notice that as you type the Entity name the Entity Set name pluralizes the Entity name.  Think of the Entity name as the class that represents a record and the Entity set as the class that represents the table of those records.
3. By default the Entity Framework will create a Primary Key called Id.  If you wish to not create a primary key you can uncheck the Create key property checkbox from the dialog box.
4. Click the OK button. The UserAccount entity will be added to the entity diagram.
5. The next step is to add properties to this entity. Properties will map to fields in a table. We'll first add the First and Last name properties.
6. Right click on the UserAccount entity and select AddàScalar property from the pop-up menu.
7. Change the property name to FirstName.
8. In the properties window change the MaxLength to 50. Scalar properties are strings by default.
9. Add another property called LastName the same way and set its MaxLength to 50.

The next step is to add and insert date and update date properties.  We like to have the inserted and updated dates on every entity just for the sake of trouble shooting.  These are two properties that will be added to every entity so it is the perfect candidate for a Complex Type.  A Complex Type allows you to define a set of properties and then associate them with multiple entities.

10. In the Model Browser window, left click on the Complex Types nodes. 
11. Change the name of the complex type to AuditFields.
12. Right click on the AuditFields complex type in the Model Browser and select AddàScalar PropertyàDateTime from the pop-up menu.
13. Change the name to InsertDate.
14. Follow the same steps to add the UpdateDate property to the complex type.
15. Now you can add the Complex property to the UserAccount entity.  Right click the UserAccount entity and select AddàComplex Property from the pop-up menu.
16. Change the name to AuditFields.  The type should have already defaulted to AuditFields.

When the database is created from this entity it will contain the two audit fields defined in the complex type.

Now let's add the address entity.  A user can have more than one address so there is a one-to-many relationship between these two entities.

17. Right click the designer and select AddàEntity from the pop-up menu.
18. Change the name to Address and then click the OK button.
19. Add scalar properties to the Address entity for Address1, Address2, City, State, and Zip. 
20. Change Address2 to be nullable by settting the Nullable property to True in the properties window.  All other properties are required.
21. Now add the Audit Fields to this entity by right clicking the Address entity and selecting AddàComplex Property from the pop-up menu.  Set the name to AuditFields and the type to AuditFields.

The next step is to create an association between the UserAccount and Address entities.

22. Right click on the UserAccount entity and select AddàAssociation from the pop-up menu.
23. The Add Association dialog appears.  It assumes correctly that you want to create a one-to-many relationship between these two entities.  You use the Multiplicity drop down to define the variations of relationships but for this example you can leave the defaults and click the OK button.  Notice that a UserAccountId property was added to the Address table.

Step 4: Generate the Database

Now that the entities are defined we can create the database.  Visual Studio makes this quite simple.  A script is generated with the correct DDL statements to create tables, indexes, and relationships which you can then execute against your database

1. Right click on the Designer and select Generate Database from Model… from the pop-up menu.  The Generate Database Wizard will appear.
2. Click the New Connection… button.
3. Enter your server name.  Choose either User Windows Authentication or Use SQL Server Authentication. 
4. Enter OrderSystem for the name of the database and click the OK button.
5. You should get a message stating "The database 'OrderSystem' does not exist or you do not have permissions to see it.  Would you like to attempt to create it?"  Click the Yes button.
6. The database should be created and you'll be returned to the Generate Database Wizard dialog.  Click the Next button.
7. The wizard will now generate the DDL statements needed to create this database.
8. Click the Finish button.


Summary

That's all you need to do to create a database using the new Entity Framework's Model First methodology. This is a big improvement over the first edition because it allows you to use Visual Studio to work through the design of you objects first and then VS can figure out how to create the database tables, indexes, and relationships for you.

What is so SPECIAL on ASPHostDirectory.com ASP. Net 4 Hosting?

We know that finding a cheap, reliable web host is not a simple task so we’ve put all the information you need in one place to help you make your decision. At ASPHostDirectory, we pride ourselves in our commitment to our customers and want to make sure they have all the details they need before making that big decision.

We will work tirelessly to provide a refreshing and friendly level of customer service. We believe in creativity, innovation, and a competitive spirit in all that we do. We are sound, honest company who feels that business is more than just the bottom line. We consider every business opportunity a chance to engage and interact with our customers and our community. Neither our clients nor our employees are a commodity. They are part of our family.

The followings are the top 10 reasons you should trust your online business and hosting needs to us:

- FREE domain for Life - ASPHostDirectory gives you your own free domain name for life with our Professional Hosting Plan and 3 free domains with any of Reseller Hosting Plan! There’s no need to panic about renewing your domain as ASPHostDirectory will automatically do this for you to ensure you never lose the all important identity of your site
- 99,9% Uptime Guarantee - ASPHostDirectory promises it’s customers 99.9% network uptime! We are so concerned about uptime that we set up our own company to monitor people’s uptime for them called ASPHostDirectory Uptime
- 24/7-based Support - We never fall asleep and we run a service that is opening 24/7 a year. Even everyone is on holiday during Easter or Christmast/New Year, we are always behind our desk serving our customers
- Customer Tailored Support - if you compare our hosting plans to others you will see that we are offering a much better deal in every aspect; performance, disk quotas, bandwidth allocation, databases, security, control panel features, e-mail services, real-time stats, and service
- Money Back Guarantee - ASPHostDirectory offers a ‘no questions asked’ money back guarantee with all our plans for any cancellations made within the first 30 days of ordering. Our cancellation policy is very simple - if you cancel your account within 30 days of first signing up we will provide you with a full refund
- Experts in ASP. Net 4 Hosting - Given the scale of our environment, we have recruited and developed some of the best talent in the hosting technology that you are using. Our team is strong because of the experience and talents of the individuals who make up ASPHostDirectory
- Daily Backup Service - We realise that your website is very important to your business and hence, we never ever forget to create a daily backup. Your database and website are backup every night into a permanent remote tape drive to ensure that they are always safe and secure. The backup is always ready and available anytime you need it
- Easy Site Administration - With our powerful control panel, you can always administer most of your site features easily without even needing to contact for our Support Team. Additionally, you can also install more than 100 FREE applications directly via our Control  Panel in 1 minute!

Happy Hosting!

 



ASPHostDirectory.com .NET 4 Hosting :: Virtualization in Silverlight 4 RC

clock July 10, 2010 10:20 by author Darwin

Introduction

There are several container controls in Silverlight . One of them is panel. Container control like for example StackPanel host another controls. Data presentation controls like ListBox inherits from ItemsControl. ItemsControl contains set of items to display and has ItemsSource property.ItemsControl is responsible for creating visuals for each item and placing them in a panel.


Main panel that holds items in ItemsControl is ItemsHost property. If we set this panel to be StackPanel for large datasets, ItemsContainerGenerator will generate containers that are off visible screen. Our ListBox will instantiate containers that aren't visible witch can take time and consume memory depending how large is dataset. Scrolling will also be much slower because we constantly computes the size and position of all of the containers.


Best solution for this problem is using UI virtualization. UI virtualization means that generation of items is deferred until we scroll items into visible zone. How it works? When we enable virtualization ItemHost property of ItemsControl is set to be VirtualizingStackPanel.


VirtualizingStackPanel calculates number of visible items and helps to create UI elements only for visible items. Scrolling on large datasets now will be much faster.


Another technique that can improve performance when working with large datasets is called Data virtualization. What does it mean? It means that we not load all data on client side rather only data that user can see at the moment. For example user in ListBox can see only 20 or 30 items. After that it must scroll. Here we can use technique called “deferred scrolling”. This technique you can see on Google Reader for example. We only loads 30 items from database and that user see. When user scroll down we load another 30 items from database. This technique can significantly improve performance of our application depend how large set of data we load on the client side.


Another example of Data virtualization is data pager control.We load 30 items in DataGrid control and when user click on link for next page then we load another 30 items.

2. UI virtualization

UI virtualization in Silverlight is accomplished by using VirtualizingStackPanel. As we have sad before VirtualizingStackPanel is that control that calculates the number of visible items to create UI elements only for visible items.

Virtualization in a StackPanel  occurs when the items control contained in the panel creates its own item containers. This happens when we use data binding. In case where item containers are created and added to the items control, a VirtualizingStackPanel offers no  advantage over a regular StackPanel.


VirtualizingStackPanel has two virtualization modes : standard and recycling. When we set standard mode containers are generated when items entering visible area. On the other hand when we set virtualization mode to be recycling we reuse containers that we have created before instead of generating new ones. Performance benefits of enabling recycling on VirtualizingStackPanel are significant especially for scrolling.

3. Data virtualization

Because off lack deferred scrolling on ScrollViewer it is not easy to implement “deferred scrolling”  in Silverlight 4 RC. In WPF we have this possibility to set deferred scrolling to true so we can make application that loads data when user releases scroll bar thumb.


But Silverlight has support for Data Virtualization using DataPager control and PagedCollectionView class. If we have DataGrid for example and we need to load large dataset with 500000 items in DataGrid maybe is better solution to implement paging on DataGrid using DataPager control.


We can use  a PagedCollectionView to provide grouping, sorting, filtering, and paging functionality for any collection that implements the IEnumerable interface. We just wrap IEnumerable collection with PageCollectionView and we have all this functionality. For example :

List<string> list = new List<string>();
//just provide to PagedCollectionView any IEnumerable datasource
PagedCollectionView p = new PagedCollectionView(list);
dataPager.Source = p;

PagedCollectionView has collection of GroupDescriptiors and SortDescriptiors that describes how items are group or sorted in view. It also contains methods for navigation between pages.

Code for grouping and sorting is simple. We just need to add new GroupDescription where we specify witch property in model will be used for grouping. For sorting code is similar. We just need to add new SortDescription and specify witch property will be used for sorting and in witch direction.

p.GroupDescriptions.Add(new PropertyGroupDescription("CustomerName"));
p.SortDescriptions.Add(new SortDescription("CustomerName",ListSortDirection.Ascending));

For filtering you need to define predicate that point to the method that will be used for filtering data.

p.Filter= new Predicate<object>(ExampleMethod);

4. Summary

As we have seen Silverlight 4 RC has very good support for UI virtualization. Using this technique we can improve performance of our Silverlight applications significantly.This give us tools to build high performance large business applications.

On the other hand Silverlight 4 RC does not support DeferredScrolling on ScrollViewer like WPF does. That makes difficult to implement “deferred scrolling” solutions in Silverlight. But probobly in later version of Silverlight this feature will be added because Silverlight and WPF eventually probably will become same platform. Silverlight also have very good support for paging through PagedCollectionView  that give us lot of functionality in simple way.

If you want to get professional Silverlight 4 RC hosting with low price, click here.

What is so SPECIAL on ASPHostDirectory.com Silverlight Hosting?

We know that finding a cheap, reliable web host is not a simple task so we’ve put all the information you need in one place to help you make your decision. At ASPHostDirectory, we pride ourselves in our commitment to our customers and want to make sure they have all the details they need before making that big decision.

We will work tirelessly to provide a refreshing and friendly level of customer service. We believe in creativity, innovation, and a competitive spirit in all that we do. We are sound, honest company who feels that business is more than just the bottom line. We consider every business opportunity a chance to engage and interact with our customers and our community. Neither our clients nor our employees are a commodity. They are part of our family.

The followings are the top 10 reasons you should trust your online business and hosting needs to us:

- FREE domain for Life - ASPHostDirectory gives you your own free domain name for life with our Professional Hosting Plan and 3 free domains with any of Reseller Hosting Plan! There’s no need to panic about renewing your domain as ASPHostDirectory will automatically do this for you to ensure you never lose the all important identity of your site
- 99,9% Uptime Guarantee - ASPHostDirectory promises it’s customers 99.9% network uptime! We are so concerned about uptime that we set up our own company to monitor people’s uptime for them called ASPHostDirectory Uptime
- 24/7-based Support - We never fall asleep and we run a service that is opening 24/7 a year. Even everyone is on holiday during Easter or Christmast/New Year, we are always behind our desk serving our customers
- Customer Tailored Support - if you compare our hosting plans to others you will see that we are offering a much better deal in every aspect; performance, disk quotas, bandwidth allocation, databases, security, control panel features, e-mail services, real-time stats, and service
- Money Back Guarantee - ASPHostDirectory offers a ‘no questions asked’ money back guarantee with all our plans for any cancellations made within the first 30 days of ordering. Our cancellation policy is very simple - if you cancel your account within 30 days of first signing up we will provide you with a full refund
- Experts in Silverlight Hosting
- Given the scale of our environment, we have recruited and developed some of the best talent in the hosting technology that you are using. Our team is strong because of the experience and talents of the individuals who make up ASPHostDirectory
- Daily Backup Service - We realise that your website is very important to your business and hence, we never ever forget to create a daily backup. Your database and website are backup every night into a permanent remote tape drive to ensure that they are always safe and secure. The backup is always ready and available anytime you need it
- Easy Site Administration - With our powerful control panel, you can always administer most of your site features easily without even needing to contact for our Support Team. Additionally, you can also install more than 100 FREE applications directly via our Control  Panel in 1 minute!

Happy Hosting!

 



ASPHostDirectory.com .NET 4 Hosting :: Sorting Out Site Collections - SharePoint 2007 Tutorial

clock July 8, 2010 07:15 by author Darwin

In SharePoint Portal Server 2003, whenever you went to the sites directory and clicked the Create Site link under the Actions menu, you were creating a site collection. Every site collection has a top level site where things such as site templates, list templates, and cross site groups existed.

Within a site collection, additional sites could be created that would share certain things (such as the template galleries and potentially permissions) with the top level site. In essence, the site collection was its own unique hierarchy of SharePoint sites and for the most part completely independent of other site collections. In a stand alone installation of WSS there was typically only one site collection. In SharePoint Server, there could be hundreds, which is why organizing them effectively in the Sites Directory and Areas (via listings) was very important and crucial. In fact, the primary role of SharePoint Portal Server -- aside from the additional functionality it provided in enterprise features such as search, audiences, and personal sites -- was the ability to organize the massive amounts of data that exists across multiple site collections better.

By default in Microsoft Office SharePoint Server 2007 (if you are using the Corporate Intranet Portal template as your default site) when you go to the "Sites" link and click the Create site button … you are instead creating a site that is a member of the site collection your portal is in.

So instead of having a portal layer and then a large number of unique collaborative collections below -- everything now exists in a single site collection by default. This is great if, within your organization, you want to "easily" share things such as templates, site columns, content types, and navigational elements. Plus security and user management is much easier using this approach.

However some organizations will still require unique site collections since their business units are very unique and very little sharing is anticipated between groups. If that is the case, then you may instead wish to create site collections from the sites directory. To do this, you need to:

- Enable Self Service Site Creation in the Central Administration (Steps Below)
- Change the configuration settings under the Sites Directory (Steps Below)

So in essence, the new way is really much better since we no longer have to manage two completely separate levels; however if you liked the old way better and want more unique site collections for your collaborative areas, you can have that too.

Enabling Self Service Site Creation

1. Log into the Central Administration Site.
2. Click Application Management
3. Click Self-service site management
4. Select the correct Web application (that step is easy to miss) and select On for Enable Self-Service Site Creation
5. Click OK

Enable the Creation of Site Collections in Sites Directory

1. From the portal, use the Site Actions menu, select Modify All Site Settings. If you are not on top level site you will need to go to Top Level Site Settings.
2. Under site collection administration, select Site Directory Settings.
3. Select the checkbox to create new site collections from sites directory.

Conclusion

The topic above contains brief information about SharePoint. This topic doesn’t provide comprehensive information about all new features and is subject to change. So, if you seek more information about MOSS 2007, you can choose ASPHostDirectory as alternatives. You’ll get the best service at an affordable price. Only with @ 24.00/month, you can directly get the services you want. So, what are you waiting for? Try it!!

What is so SPECIAL on ASPHostDirectory.com Sharepoint Hosting?

We know that finding a cheap, reliable web host is not a simple task so we’ve put all the information you need in one place to help you make your decision. At ASPHostDirectory, we pride ourselves in our commitment to our customers and want to make sure they have all the details they need before making that big decision.

We will work tirelessly to provide a refreshing and friendly level of customer service. We believe in creativity, innovation, and a competitive spirit in all that we do. We are sound, honest company who feels that business is more than just the bottom line. We consider every business opportunity a chance to engage and interact with our customers and our community. Neither our clients nor our employees are a commodity. They are part of our family.

The followings are the top 10 reasons you should trust your online business and hosting needs to us:

- FREE domain for Life - ASPHostDirectory gives you your own free domain name for life with our Professional Hosting Plan and 3 free domains with any of Reseller Hosting Plan! There’s no need to panic about renewing your domain as ASPHostDirectory will automatically do this for you to ensure you never lose the all important identity of your site
- 99,9% Uptime Guarantee - ASPHostDirectory promises it’s customers 99.9% network uptime! We are so concerned about uptime that we set up our own company to monitor people’s uptime for them called ASPHostDirectory Uptime
- 24/7-based Support - We never fall asleep and we run a service that is opening 24/7 a year. Even everyone is on holiday during Easter or Christmast/New Year, we are always behind our desk serving our customers
- Customer Tailored Support - if you compare our hosting plans to others you will see that we are offering a much better deal in every aspect; performance, disk quotas, bandwidth allocation, databases, security, control panel features, e-mail services, real-time stats, and service
- Money Back Guarantee - ASPHostDirectory offers a ‘no questions asked’ money back guarantee with all our plans for any cancellations made within the first 30 days of ordering. Our cancellation policy is very simple - if you cancel your account within 30 days of first signing up we will provide you with a full refund
- Experts in Sharepoint Hosting
- Given the scale of our environment, we have recruited and developed some of the best talent in the hosting technology that you are using. Our team is strong because of the experience and talents of the individuals who make up ASPHostDirectory
- Daily Backup Service - We realise that your website is very important to your business and hence, we never ever forget to create a daily backup. Your database and website are backup every night into a permanent remote tape drive to ensure that they are always safe and secure. The backup is always ready and available anytime you need it
- Easy Site Administration - With our powerful control panel, you can always administer most of your site features easily without even needing to contact for our Support Team. Additionally, you can also install more than 100 FREE applications directly via our Control  Panel in 1 minute!

Happy Hosting!

 



ASPHostDirectory.com .NET 4 Hosting :: What's New in C# and .NET 4

clock July 6, 2010 05:55 by author Darwin

While .NET 3.0 and 3.5 were great additions to the .NET framework, they were built against the 2.0 Common Language Runtime (CLR). Now, Microsoft has released .NET 4 – in addition to a new CLR, we've got a ton of framework and language improvements. We'll cover some of those changes here and will continue to cover .NET 4 in future articles.

C# Language


Let's start by covering a few of the new features of the C# language. After that, we'll check out some IDE enhancements to make your C# development experience more productive.

Named and Optional Arguments

With support for named arguments, you can reduce the amount of typing you need to do when calling a method (or indexer, constructor or delegate).

Let's say you have a method with 4 arguments (x, y, width and height). And because this API was designed nicely, the arguments are actually named "x", "y", "width" and "height". When it comes time to calling that method, if you can only remember the argument names but not their position, named arguments will help:


CalulateIntersection(x: 20, y: 30, height: 10, width: 4);

Or maybe it was width and height that went first?

CalulateIntersection(height: 10, width: 4, x: 20, y: 30);

With named arguments, both of these calls are equivalent and pass the same data to the method.

Optional arguments allow you to specify a default value for an argument. The default value will be used if the caller does not provide a value for the optional parameter. The syntax is simple:

public void MakeBeta(int value, string name = "Beta1", string version = "1.0")

In the method signature above, name and version are optional. If not supplied by the caller, "name" will get the value "Beta1" and "version" will be "1.0". Even though optional parameters are, um, optional, you can't leave them out altogether. If you wanted to call "MakeBeta" with the default name but a specific version, you can use named arguments:

MakeBeta(34, version: "2.4");

If you've done any COM-interop, especially with the Microsoft Office COM API's, you'll quickly see how powerful optional and named arguments will be to you. Before named arguments, you had to use Type.Missing for optional parameters:

excelApp.get_Range("A5", "C7").AutoFormat(myFormat, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing);


Now you can take advantage of named arguments and simply supply the format argument:

excelApp.get_Range("A5", "C7").AutoFormat(format:myFormat);

Dynamic keyword

The "dynamic" keyword allows you to define a type that has its type checking done at runtime rather than compile time. Why would you want to wait until runtime to do your type checking? It allows your application to be more flexible: You don't care where an object came from – COM interop, reflection, a dynamic language like IronPython – you just want to manipulate it.


Consider this example:

public void DoSomething(dynamic x)
      {
            x.ShowSample();
      }

Since "x" is defined as dynamic, no compile-time checks are done. At runtime, the code will work only if the object passed in supports a "ShowSample" method that takes no arguments. It doesn't matter what the type is – as long as it has a "ShowSample" method.

Why defer type checking to runtime? The biggest reason is COM-interop. If you look at some of the Microsoft Office Automation API interfaces, there are a lot of variables and return types defined as "object". This is because the API's were originally designed for a non-type-safe language: VBScript.


With .NET's adherence to strong typing, interop with COM API's like the Microsoft Office API's requires a lot of casting to various interfaces and classes in both method calls as well as return types. It made the code tedious to write and difficult to read.


With the dynamic keyword, we can let the runtime do the type checking and casting for us. A call to set or get the value of a range used to look something like this:

      ((Microsoft.Office.Interop.Excel.Range)excelApp.Cells[5, 5]).Value = "Language";
      var languageRange = (Microsoft.Office.Interop.Excel.Range)excelApp.Cells[5, 5];


Now, by defining the "excelApp" variable as "dynamic", we can let the runtime do the type checking and there is no longer a need to satisfy the compiler with casting:

      excelApp.Cells[5, 5].Value = "Language";
      var languageRange = excelApp.Cells[5, 5];

Type Equivalence Support

Type Equivalence Support (or "Type Embedding") allows you to avoid a major pitfall of writing clients against strongly-type interop assemblies; that is, when a new version of the strongly-typed interop assembly is released, you have to recompile your client – even if you're not using any of the new features.

With type embedding, you can actually embed type information into a client. So if the type information changes on the target machine (because the user upgraded to the next version of Microsoft Office, for example), the type information embedded into the client can be used without the need to recompile the client application.

A simple example of how this works is beyond the scope of this article. See the MSDN documentation on "Walkthrough: Embedding Types from Managed Assemblies" for a complete explanation and sample code.


Covariance and Contravariance

This is one of those tricky things that could take up an entire article. As a matter of fact, former "C# Corner" author Bill Wagner did just that back in May of 2009. His article, "Generic Covariance and Contravariance in C# 4.0" provides an in-depth look at how C# handles type conversions and decides which ones are allowed and which aren't.

C# IDE

The C# language wasn't the only part of C# that was improved. Microsoft spent a lot of time on Visual Studio as well. The IDE shell was rewritten in WPF (ever heard of the term "eating your own dog food?") and uses MEF (Managed Extensibility Framework) to offer even more extensibility points. Here are a few C# IDE enhancements in 2010.

Generate From Usage

As a fan of test-first development, I like the new "Generate From Usage" feature.


Let's say we’re writing a simple banking application and we need to write some code to transfer some money between two accounts. Let’s start with a unit test:

      [TestMethod]
      public void TransferFundsTest()
      {
            Account source = new Account() {Balance = 300.0};
            Account destination = new Account() {Balance = 100.0};
            var xferService = new XferService();

            xferService.Transfer(source, destination, 50.0);

            Assert.AreEqual(250, source.Balance);
            Assert.AreEqual(150, destination.Balance);
      }

Lots of errors in there! That’s because we haven’t even written an Account class or an XferService class. Visual Studio can help us start generating some code based on our unit test.

Right-click on the one of the red "Account" instances and select "Generate" and then "Class". Visual Studio generates a simple Account class with no members. Now right-click on one of the red "Balance" references and select "Generate" and then "Property". Our Account class now has a simple get/set Balance field. Repeat these same steps with XferService and the Transfer method. Without too much work, we’ve got the following code generated from our unit tests:


      class Account
      {
            public double Balance { get; set; }
      }

      class XferService
      {
            internal void Transfer(Account source, Account destination, double p)
            {
                  throw new NotImplementedException();
            }

}

Reference Highlighting

Reference Highlighting adds a nice navigational feature to the IDE. Select any word in the IDE. You’ll notice that all instances of that word are highlighted in the code editor. It’s a quick way to show you where usages of that word object (class, variable, method, property) can be found. And you can navigate between all highlighted instances with CTRL+SHIFT+DOWN ARROW and CTRL+SHIFT+UP ARROW.

Conclusion

All in all, Microsoft has done a very nice job of putting lots of features into both C# and the Visual Studio IDE. Remember, this article covered just a few of the highlights. So, if you’re looking for ASP.NET 4.0 hosting, you can choose ASPHostDirectory as the alternatives. You can start from $ 3.99/month to get the professional ASP.NET 4.0 hosting. What are you waiting for?

What is so SPECIAL on ASPHostDirectory.com ASP. Net 4 Hosting?

We know that finding a cheap, reliable web host is not a simple task so we’ve put all the information you need in one place to help you make your decision. At ASPHostDirectory, we pride ourselves in our commitment to our customers and want to make sure they have all the details they need before making that big decision.

We will work tirelessly to provide a refreshing and friendly level of customer service. We believe in creativity, innovation, and a competitive spirit in all that we do. We are sound, honest company who feels that business is more than just the bottom line. We consider every business opportunity a chance to engage and interact with our customers and our community. Neither our clients nor our employees are a commodity. They are part of our family.

The followings are the top 10 reasons you should trust your online business and hosting needs to us:

- FREE domain for Life - ASPHostDirectory gives you your own free domain name for life with our Professional Hosting Plan and 3 free domains with any of Reseller Hosting Plan! There’s no need to panic about renewing your domain as ASPHostDirectory will automatically do this for you to ensure you never lose the all important identity of your site
- 99,9% Uptime Guarantee - ASPHostDirectory promises it’s customers 99.9% network uptime! We are so concerned about uptime that we set up our own company to monitor people’s uptime for them called ASPHostDirectory Uptime
- 24/7-based Support - We never fall asleep and we run a service that is opening 24/7 a year. Even everyone is on holiday during Easter or Christmast/New Year, we are always behind our desk serving our customers
- Customer Tailored Support - if you compare our hosting plans to others you will see that we are offering a much better deal in every aspect; performance, disk quotas, bandwidth allocation, databases, security, control panel features, e-mail services, real-time stats, and service
- Money Back Guarantee - ASPHostDirectory offers a ‘no questions asked’ money back guarantee with all our plans for any cancellations made within the first 30 days of ordering. Our cancellation policy is very simple - if you cancel your account within 30 days of first signing up we will provide you with a full refund
- Experts in ASP. Net 4 Hosting - Given the scale of our environment, we have recruited and developed some of the best talent in the hosting technology that you are using. Our team is strong because of the experience and talents of the individuals who make up ASPHostDirectory
- Daily Backup Service - We realise that your website is very important to your business and hence, we never ever forget to create a daily backup. Your database and website are backup every night into a permanent remote tape drive to ensure that they are always safe and secure. The backup is always ready and available anytime you need it
- Easy Site Administration - With our powerful control panel, you can always administer most of your site features easily without even needing to contact for our Support Team. Additionally, you can also install more than 100 FREE applications directly via our Control  Panel in 1 minute!

Happy Hosting!

 



ASPHostDirectory.com .NET 4 Hosting :: New Syntax for HTML Encoding Output in ASP.NET 4 (and ASP.NET MVC 2)

clock July 6, 2010 05:52 by author Darwin

Today’s post covers a small, but very useful, new syntax feature being introduced with ASP.NET 4 – which is the ability to automatically HTML encode output within code nuggets.  This helps protect your applications and sites against cross-site script injection (XSS) and HTML injection attacks, and enables you to do so using a nice concise syntax.

HTML Encoding

Cross-site script injection (XSS) and HTML encoding attacks are two of the most common security issues that plague web-sites and applications.  They occur when hackers find a way to inject client-side script or HTML markup into web-pages that are then viewed by other visitors to a site.  This can be used to both vandalize a site, as well as enable hackers to run client-script code that steals cookie data and/or exploits a user’s identity on a site to do bad things.

One way to help mitigate against cross-site scripting attacks is to make sure that rendered output is HTML encoded within a page.  This helps ensures that any content that might have been input/modified by an end-user cannot be output back onto a page containing tags like <script> or <img> elements. 

How to HTML Encode Content Today

ASP.NET applications (especially those using ASP.NET MVC) often rely on using <%= %> code-nugget expressions to render output.  Developers today often use the Server.HtmlEncode() or HttpUtility.Encode() helper methods within these expressions to HTML encode the output before it is rendered.  This can be done using code like below:

<div class=”article-content”>
        <%= Server.HtmlEncode(Model.Content) %>
</div>

While this works fine, there are two downsides of it:

1. It is a little verbose
2. Developers often forget to call the Server.HtmlEncode method – and there is no easy way to verify its usage across an app

New <%: %> Code Nugget Syntax

With ASP.NET 4 we are introducing a new code expression syntax (<%:  %>) that renders output like <%= %> blocks do – but which also automatically HTML encodes it before doing so.  This eliminates the need to explicitly HTML encode content like we did in the example above.  Instead, you can just write the more concise code below to accomplish the exact same thing:

<div class=”article-content”>
       <%: Model.Content %>
</div>

We chose the <%: %> syntax so that it would be easy to quickly replace existing instances of <%= %> code blocks.  It also enables you to easily search your code-base for <%= %> elements to find and verify any cases where you are not using HTML encoding within your application to ensure that you have the correct behavior. application to ensure that you have the correct behavior.

Avoiding Double Encoding

While HTML encoding content is often a good best practice, there are times when the content you are outputting is meant to be HTML or is already encoded – in which case you don’t want to HTML encode it again. 

ASP.NET 4 introduces a new IHtmlString interface (along with a concrete implementation: HtmlString) that you can implement on types to indicate that its value is already properly encoded (or otherwise examined) for displaying as HTML, and that therefore the value should not be HTML-encoded again.  The <%: %> code-nugget syntax checks for the presence of the IHtmlString interface and will not HTML encode the output of the code expression if its value implements this interface.  This allows developers to avoid having to decide on a per-case basis whether to use <%= %> or <%: %> code-nuggets.  Instead you can always use <%: %> code nuggets, and then have any properties or data-types that are already HTML encoded implement the IHtmlString interface.

Using ASP.NET MVC HTML Helper Methods with <%: %>

For a practical example of where this HTML encoding escape mechanism is useful, consider scenarios where you use HTML helper methods with ASP.NET MVC.  These helper methods typically return HTML.  For example: the Html.TextBox() helper method returns markup like <input type=”text”/>.  With ASP.NET MVC 2 these helper methods now by default return HtmlString types – which indicates that the returned string content is safe for rendering and should not be encoded by <%: %> nuggets. 

This allows you to use these methods within both <%= %> code nugget blocks:

<%= Html.TextBoxFor(article=>article.Content) %>

As well as within <%: %> code nugget blocks:

<%: Html.TextBoxFor(article=>article.Content) %>

In both cases above the HTML content returned from the helper method will be rendered to the client as HTML – and the <%: %> code nugget will avoid double-encoding it.

This enables you to default to always using <%: %> code nuggets instead of <%= %> code blocks within your applications.  If you want to be really hardcore you can even create a build rule that searches your application looking for <%= %> usages and flags any cases it finds as an error to enforce that HTML encoding always takes place.

Scaffolding ASP.NET MVC 2 Views

When you use VS 2010 (or the free Visual Web Developer 2010 Express) to build ASP.NET MVC 2 applications, you’ll find that the views that are scaffolded using the “Add View” dialog now by default always use <%: %> blocks when outputting any content.  For example, below I’ve scaffolded a simple “Edit” view for an Article object.  Note the three usages of <%: %> code nuggets for the label, textbox, and validation message (all output with HTML helper methods):

<h2>Edit Article</h2>

<% using (Html.BeginForm()) {%>

         <fieldset>

                <div class=”editor-label”>
                       <%: Html.LabelFor(model => model.Content) %>
                </div>
                <div class=”editor-field”>
                       <%: Html.TextBoxFor(model => model.Content) %>
                       <%: Html.ValidationMessageFor(model => model.Content) %>
                </div>

Summary

The new <%: %> syntax provides a concise way to automatically HTML encode content and then render it as output.  It allows you to make your code a little less verbose, and to easily check/verify that you are always HTML encoding content throughout your site.  This can help protect your applications against cross-site script injection (XSS) and HTML injection attacks. If you looking for ASP.NET 4.0 hosting, you only need to pay $ 3.99/month to get ASP.NET 4.0 hosting. You only get this opportunity in ASPHostDirectory.

What is so SPECIAL on ASPHostDirectory.com ASP. Net 4 Hosting?

We know that finding a cheap, reliable web host is not a simple task so we’ve put all the information you need in one place to help you make your decision. At ASPHostDirectory, we pride ourselves in our commitment to our customers and want to make sure they have all the details they need before making that big decision.

We will work tirelessly to provide a refreshing and friendly level of customer service. We believe in creativity, innovation, and a competitive spirit in all that we do. We are sound, honest company who feels that business is more than just the bottom line. We consider every business opportunity a chance to engage and interact with our customers and our community. Neither our clients nor our employees are a commodity. They are part of our family.

The followings are the top 10 reasons you should trust your online business and hosting needs to us:

- FREE domain for Life - ASPHostDirectory gives you your own free domain name for life with our Professional Hosting Plan and 3 free domains with any of Reseller Hosting Plan! There’s no need to panic about renewing your domain as ASPHostDirectory will automatically do this for you to ensure you never lose the all important identity of your site
- 99,9% Uptime Guarantee - ASPHostDirectory promises it’s customers 99.9% network uptime! We are so concerned about uptime that we set up our own company to monitor people’s uptime for them called ASPHostDirectory Uptime
- 24/7-based Support - We never fall asleep and we run a service that is opening 24/7 a year. Even everyone is on holiday during Easter or Christmast/New Year, we are always behind our desk serving our customers
- Customer Tailored Support - if you compare our hosting plans to others you will see that we are offering a much better deal in every aspect; performance, disk quotas, bandwidth allocation, databases, security, control panel features, e-mail services, real-time stats, and service
- Money Back Guarantee - ASPHostDirectory offers a ‘no questions asked’ money back guarantee with all our plans for any cancellations made within the first 30 days of ordering. Our cancellation policy is very simple - if you cancel your account within 30 days of first signing up we will provide you with a full refund
- Experts in ASP. Net 4 Hosting
- Given the scale of our environment, we have recruited and developed some of the best talent in the hosting technology that you are using. Our team is strong because of the experience and talents of the individuals who make up ASPHostDirectory
- Daily Backup Service - We realise that your website is very important to your business and hence, we never ever forget to create a daily backup. Your database and website are backup every night into a permanent remote tape drive to ensure that they are always safe and secure. The backup is always ready and available anytime you need it
- Easy Site Administration - With our powerful control panel, you can always administer most of your site features easily without even needing to contact for our Support Team. Additionally, you can also install more than 100 FREE applications directly via our Control  Panel in 1 minute!

Happy Hosting!