ASPHostCentral.com ASP.NET MVC Hosting BLOG

All about ASP.NET MVC 4.0 Hosting, ASP.NET MVC 3.0 Hosting and ASP.NET MVC Hosting articles

Press Release - ASPHostCentral.com now offers IIS 8 Hosting on Windows Server 2012

clock September 26, 2012 19:28 by author Administrator

ASPHostCentral.com, the premier Windows and ASP.NET Hosting provider, proudly announces the availability of IIS8 Hosting on our most advanced Windows 2012 hosting platform. ASPHostCentral.com supports .NET Framework 4.5, so you can run apps built with ASP.NET 4.5, Visual Studio 2012, and Visual Studio Express 2012. We also support ASP.NET MVC 4, Silverlight 5, One-Click Publish and WebMatrix Hosting!

This IIS 8 service is bundled with our newest Windows Server 2012. Within Windows Server® 2012 you will find exciting innovations in areas of virtualization, networking, storage, user experience as well as an improved integration with Windows PowerShell® which takes scripting to a whole new level. This is quite possibly the most significant release of Windows Server® ever.

What is new in IIS 8.0 for Windows Server® 2012?

- FTP Logon Attempt Restrictions
- CPU Throttling: Sand-box for sites and applications
- Application Initialization Module
- Centralized management of SSL certificates
- Server Name Indication (SNI): SSL Scalability
- Use ASP.NET 3.5 and 4.5
- ASP.NET Configuration Management
- Dynamic IP Address Restrictions
- Multicore Scaling on NUMA hardware

Our IIS 8  Hosting Packages

Our IIS 8 Windows Hosting Package starts from as low as $4.49/month only and the package has included the following features:

- Windows Server 2012
- World Class Control Panel
- ASP.NET 4.5 and ASP.NET MVC 4
- Silverlight 5
- WCF RIA Service
- VS 2012
- VS Lightswitch
- WebMatrix
- One-click publish
- SQL 2012

For more information, please contact ASPHostCentral.com.

Currently rated 3.0 by 5 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


VS 2012 Hosting :: ASP.NET Web Forms 4.5 new features in Visual Studio 2012

clock September 24, 2012 17:13 by author Administrator

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

If you like to host your ASP.NET Web Forms 4.5, you can have a look at
asphostcentral.com

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



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



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



Strongly typed Data Controls

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



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



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



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

Model Binding

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



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



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

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

Advantage of using Model Binding


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

Support for OpenID in OAuth Logins



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

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

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

        

Currently rated 1.9 by 17 people

  • Currently 1.941176/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


ASPHostCentral.com now supports SharePoint 2013 Hosting

clock September 13, 2012 17:51 by author Administrator

ASPHostCentral.com, the leader in ASP.NET and Windows Hosting Provider, proudly announces that we have supported the latest SharePoint 2013 Hosting

We offer this newest
SharePoint 2013 Hosting Package from just $15.99/month. Our SharePoint 2013 hosting plan comes with a list of complete features, such as:

- Massive Document Storage Space
- Massive Bandwidth
- Unlimited Number of SharePoint Users / Accounts
- SharePoint Designer 2013
- Support Third-Party (Custom) Web Parts)
- Support International Language Packs
- Support SSL for higher data integrity
- Support Anonymous, Public-Facing Access

To make our SharePoint 2013 even more complete, we have added extra features free of charge to the package. These features are:

- .NET 4.5 and ASP.NET MVC 4.0 Framework
- Silverlight 5.0
- SQL Server 2012
- Entity Framework (EF)
- WebMatrix and WebDeploy
- Windows 2012 Hosting
- WCF RIA Service
- World Class Control Panel
- 24/7 Support
- 99.9% Uptime Guarantee
- Choice of US or European Data Center
- 30-days Money Back Guarantee

SharePoint 2013 is the new way to work together. A simplified user experience helps you organize, sync and share all your content. New social capabilities make it easy to share ideas, keep track of what your colleagues are working on, and discover experts you never knew existed.

Putting a SharePoint team website in place for your business is a fast, cost-effective way to facilitate team communication while creating a professional looking website. Team sites based on Windows SharePoint Services are useful right out of the box. You can customize your site, changing its appearance and adding functionalities without using other applications or doing any programming

Obviously, we still support the SharePoint 2010 Hosting on our Windows Server environment.

Currently rated 1.5 by 10 people

  • Currently 1.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


.NET MVC 4.0 Hosting :: ASP.NET MVC 4 and working with HTML5 Chart Helper Extension

clock September 10, 2012 15:41 by author Administrator

With the introduction of ASP.NET MVC, the traditional ‘Control’ model of GUI component development went away. Instead it was replaced with the more Web 2.0 style JavaScript and jQuery plugin extensibility model. Nevertheless, adding incremental features to existing HTML components was always required and towards this end Microsoft introduced the HtmlHelper and helper extensions. Helper extensions are .NET extension methods that return a string. Typically, this string is formatted HTML content.

In our sample today we create an extension that renders a bar chart on HTML5 Canvas. It can be bound to a data source from the server side or be assigned data source from the client side.

Building a Html Helper Extension

Html Helper extensions are easy to build. Just follow the steps below to create our helper skeleton.

Step 1: We start with an MVC project and pick the Blank template.

Note we could pick a class library project template too and add package references as follows (via the Nuget package manager as follows)

a. PM> install-package Microsoft.AspNet.Mvc
b. Add reference to System.Web.dll from the ‘Add References’ dialog for the project

Step 2: Add a static class called ChartExtensions. Extension methods, by design, have to be defined in Static classes.

Step 3: Next add a static method Chart whose first parameters is this HtmlHelper and subsequent parameters are values required for rendering the chart.



a. The dataSource is a list of integer arrays. For the example we have assumed a two dimensional array would be provided as a data source. We can make it more sophisticated by making it an array of objects and binding to different properties of the object.
b. xTitle: The text to be displayed on the x-axis.
c. yTitle: The text to be displayed on the y-axis.

Step 4: Next we setup two methods, one to convert the dataSource to JSON and the other to generate the required HTML.



a. The GetDataSourceFromIntArray method uses the System.Web.Helpers’ Json static class to convert the input data source into a Json String. This string is assigned to a variable called arrDataSource and the whole string is returned.
b. The SetupHtml method implements the rendering logic

Step 5: Using TagBuilder to build the Html: ASP.NET provides us with the TagBuilder class that has helper methods to help create HTML elements easily. We use the TagBuilder to create our HTML layout as follows

<div>
<canvas …> … </canvas>
<script …> … </script>
<noscript> … </noscript>
</div>

The actual code is as follows


a. As seen above, the TagBuilder object has an Attributes collection to which we can add the HTML attributes we need. To set text between the opening tag and closing tag, we use the SetInnerText. However unlike an XmlTextWriter, we can’t nest tags. To nest tags we simply assign the string representation of the TagBuilder to the InnerHtml of the parent TagBuilder. So the ‘container’ Tag Builder has the <div> that encapsulates the Canvas and the Script tags.
b. We have created a 400x600 canvas area. The chartName parameter is used for the id of the canvas element.
c. For now we have an empty SetupScript method. This method will eventually build the JavaScript required to render the bar graph.
d. The <noscript> tag holds the message to display when JavaScript is not enabled on the browser.
e. Point to note is the HtmlString object that is returned. The HtmlString is a special object that indicates to the Razor view engine that it should not Html Encode this string any further. If we use string instead of HtmlString, the Razor engine automatically Html Encodes the string and we see the markup as text instead of rendered Html.

Step 6: The SetupScript method: The setup script method has the JavaScript that actually renders the chart on the canvas. The original code is borrowed (with permission) from this project. A demo for it is available here. We have to make the following changes so that it accepts any data source instead of the fixed data source assigned to it in the demo. We have also updated the code to use the strings passed in for x-axis and y-axis labels. Beyond this the animation and rendering code is pretty much the same.

a. The variable initialization change

Earlier we had a hard-coded array of strings that was rendered on the canvas. Now we have the Json string that is created from the data source that was passed to the helper.
b. Changes to the barChart() method to set data source on the client side.

In the barChart method we earlier had no parameters and the elementId was hard-coded, now we use the value that’s passed into the helper.
We also pass a data parameter that is assigned to the data source of the graph.
c. Changes in drawMarkers() method to use the values passed into the helper for the x-axis and y-axis label

d. Changes to handle two-dimensional array of points instead of one-dimensional array of comma separated strings.


In the original code, the data source is an array of strings. Each element in the array has two comma separated values, represent the year (at index-0) and number of hits (at index-1). We have updated our data source to be a two-dimensional array and hence we don’t need to do a string split to get the value. We directly access the value using appropriate indexes. This change is at three places in the code. One of them is shown above.

With these changes in place our Chart, HtmlHelper is ready to be tested in an ASP.NET Web Application

Integrating the Custom Helper in a MVC Web Application

With our Helper all set, we add an MVC Web Application to our solution and call it DotNetCurry.HtmlHelpers.WebHarness. We use the Internet template that gives us a default Index.cshtml to put our Helper in. The following steps guide us through the integration effort

Step 1: Add Reference to the HtmlHelper project.

Step 2: Add a Model class in the Models folder.


This is our view model that will hold the data to be rendered in the Graph.

Step 3: Update the HomeController to create and pass sample data model.



As seen above, we create an instance of our ViewModel class and add some test data into it. We pass this data on to the Index view, where the HtmlHelper will use it.

Step 4: Update the Index.cshtml markup to use the helper


The changes in Index.cshtml highlighted above, from top to bottom are as follows

a. Declare the model to be used in the page.
b. Add using to include the custom HtmlHelper
c. Added the HtmlForm inside which we use our Chart Helper extension. We give it an id=’sampleChart’, pass it the Model.Data and provide the labels for the x and y axes.
d. Finally in the jQuery document ready function, we initialize the chart by calling the barChart() method.
e. Our final effort looks as follows.



To change the graph change the data set coming from the controller.

That brings us to the end of this tutorial. We round off with some of the improvements possible.

Possible Improvements

1. Update the script to be able to bind to any Json object.
2. Use jQuery plugin syntax so that more than one helper can be created per page.
3. Allow more flexibility like passing parameters for bar colors, size of chart etc.
4. Allow multiple data sources to show comparison side by side.
5. Add more chart types like Pie etc.

Conclusion

Though they sound esoteric HtmlHelper extensions is a rather simple mechanism to inject rich functionality in a componentized way in ASP.NET MVC applications. We converted an existing HTML5 chart, originally created using plain HTML5 and JavaScript into a Chart HtmlHelper with very little code. For large projects, HtmlHelpers are a neat way to encapsulate small pieces of re-usable UI functionality.

Currently rated 2.2 by 14 people

  • Currently 2.214286/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


ASP.NET MVC Hosting

ASPHostCentral is a premier web hosting company where you will find low cost and reliable web hosting. We have supported the latest ASP.NET 4.5 hosting and ASP.NET MVC 4 hosting. We have supported the latest SQL Server 2012 Hosting and Windows Server 2012 Hosting too!


Sign in