Windows 2012 Hosting - MVC 6 and SQL 2014 BLOG

Tutorial and Articles about Windows Hosting, SQL Hosting, MVC Hosting, and Silverlight Hosting

Silverlight 5 Hosting - ASPHostPortal :: Playing HTML5 Video with fall back for IE8/IE7 and earlier versions of other browsers using Silverlight

clock May 30, 2012 08:12 by author Jervis

One of the popular HTML5 tags is the video tag. The ability to play videos without depending on a plugin is something that excites web developers to a great extent and no wonder you end up seeing video demos in all HTML5 conferences.

Now, coming to HTML5 Video, the tag itself is simply <video id=”ID” src=”FILENAME.mp4/ogv/webm” > in the simplest form. This also means that the video needs to be H.256 encoded MP4 format or some of the other formats as mentioned above. For a detailed specification on this, check this
Wikipedia article

HTML5 video is supported by all the modern browsers such as IE9 (currently in RC stage), Mozilla Firefox 4 and Chrome latest versions. Here below is a simple example of a HTML5 video tag and the screen shot of how it looks like in IE9 RC


<!DOCTYPE html>
<head></head>
<body>
<h1>This is a sample of an HTML5 Video</h1>
<video src="video.mp4" id="myvideo">Your browser doesn’t support this currently</video>
</body>
</html>




You can add attributes to the video tag such as “autoplay” which will automatically start playing the video. Also, you can specify “poster” to display an initial picture before the video starts playing etc., but I am not going into those for now.


This would play well in the modern browsers as mentioned above. However, if the end users are viewing this page from an earlier version of browsers such as IE8/IE7 or IE6, this video wouldn’t play. Whatever text that is specified between the video tags, would just show up.




Note: for demo purposes, I went to the IE9 developer toolbar and chose IE8 as Browser Mode to exhibit this legacy behaviour.


However, in the interest of serving the larger community of users who visit the site, we would like to have a fall back mechanism for playing videos on older version of browsers.


Now, Silverlight is supported in IE6/7 & 8 and other browsers too. If we can have the same video encoded for Silverlight, we can put the fall-back code, as follows:-


<video src="videos/video.mp4" id="myvideo">
<object height="252" type="application/x-silverlight-2" width="448">
<param name="source" value="resources/player.xap">
<param name="initParams" value="deferredLoad=true, duration=0, m=http://localhost/DemoSite/videos/video.mp4, autostart=false, autohide=true, showembed=true, postid=0" />
<param name="background" value="#00FFFFFF" />
</object>

</video>

Note, this sample uses a Silverlight XAP file with the same video and uses the object tag to embed it instead of the HTML5 video tag.


So, when I now run this sample and switch to IE8 (using the IE9 Developer toolbar’s Browser Mode), I get



and when clicking on the “Play” icon,



Note, there are multiple ways to play videos in Silverlight and this is one of the ways. For a complete list of Silverlight samples, visit http://www.silverlight.net/learn/

Also, we can use Flash to play video in the fall-back mechanism as well.

Thus, we can create a fall-back mechanism for playing HTML5 videos for the older browsers and hence ensure that the end users get to experience the same.

Cheers !!! Try Silverlight 5 Hosting with ASPHostPortal.com

 



SQL 2012 Hosting - ASPHostPortal :: Sequence in SQL Server 2012

clock May 25, 2012 07:55 by author Jervis

SQL Server 2012 (or Denali) has now arrived CTP. In this article I will look at a core new feature of SQL Server 2012 which is SEQUENCE. Well, if you are familiar with Oracle, you will already know all about this feature since it has been standard on Oracle more than 10 years I guess.

What is Sequence in SQL Server ?


In simple terms, it is a new database object and a substitute for the Identity of columns.


Using the identity attribute for a column, you can easily generate auto-incrementing numbers (which as often used as a primary key). With Sequence, it will be a different object which you can attach to a table column while inserting. Unlike identity, the next number for the column value will be retrieved from memory rather than from the disk – this makes Sequence significantly faster than Identity. We will see this in coming examples.


Creating a Sequence in SQL Server


To use Sequence first SQL Server Management Studio (SSMS) and expand the Object explorer, under programmability you will see the sequence node.




If you right click the sequence and select new, you will be taken to the below screen which has all the attributes for the sequence.




Since Sequence is a database object, it needs to be assigned to a schema. It has a data type which can be int, bigint, tinyint, smallint,numeric or decimal. The start value and increment as similar as to the values you will be familiar with using Identity.


The Minimum and maximum are boundaries for the sequence. When the cycle option is set you have the ability to re-use sequence numbers.


Similarly, Sequences can be created using T-SQL as follows.


IF EXISTS (SELECT * FROM sys.sequences WHERE name = N’EmployeeSeq’)
DROP SEQUENCE EmployeeSeq;
GO


CREATE SEQUENCE EmployeeSeq AS tinyint
START WITH 0
INCREMENT BY 5;
GO


Now let us see how we can integrate this with an Insert statement.


First we will create a table to incorporate the sequence we created.


CREATE TABLE Employee
(ID tinyint, Name varchar(150) )


Then we will insert:


INSERT INTO Employee
(ID,Name)
VALUES
(NEXT VALUE FOR EmployeeSeq, ‘Dinesh’)
INSERT INTO Employee
(ID,Name)

VALUES
(NEXT VALUE FOR EmployeeSeq, ‘Asanka’)

Note that you are now using the EmployeeSeq sequence object for the insert.

Reasons why you must trust ASPHostPortal.com


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

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


-
DELL Hardware
Dell hardware is engineered to keep critical enterprise applications running around the clock with clustered solutions fully tested and certified by Dell and other leading operating system and application providers.
- Recovery Systems
Recovery becomes easy and seamless with our fully managed backup services. We monitor your server to ensure your data is properly backed up and recoverable so when the time comes, you can easily repair or recover your data.

- Control Panel
We provide one of the most comprehensive customer control panels available. Providing maximum control and ease of use, our Control Panel serves as the central management point for your ASPHostPortal account. You’ll use a flexible, powerful hosting control panel that will give you direct control over your web hosting account. Our control panel and systems configuration is fully automated and this means your settings are configured automatically and instantly.

- Excellent Expertise in Technology
The reason we can provide you with a great amount of power, flexibility, and simplicity at such a discounted price is due to incredible efficiencies within our business. We have not just been providing hosting for many clients for years, we have also been researching, developing, and innovating every aspect of our operations, systems, procedures, strategy, management, and teams. Our operations are based on a continual improvement program where we review thousands of systems, operational and management metrics in real-time, to fine-tune every aspect of our operation and activities. We continually train and retrain all people in our teams. We provide all people in our teams with the time, space, and inspiration to research, understand, and explore the Internet in search of greater knowledge. We do this while providing you with the best hosting services for the lowest possible price.

- Data Center

ASPHostPortal modular Tier-3 data center was specifically designed to be a world-class web hosting facility totally dedicated to uncompromised performance and security
- Monitoring Services
From the moment your server is connected to our network it is monitored for connectivity, disk, memory and CPU utilization – as well as hardware failures. Our engineers are alerted to potential issues before they become critical.

- Network
ASPHostPortal has architected its network like no other hosting company. Every facet of our network infrastructure scales to gigabit speeds with no single point of failure.

- Security
Network security and the security of your server are ASPHostPortal’s top priorities. Our security team is constantly monitoring the entire network for unusual or suspicious behavior so that when it is detected we can address the issue before our network or your server is affected.

- Support Services
Engineers staff our data center 24 hours a day, 7 days a week, 365 days a year to manage the network infrastructure and oversee top-of-the-line servers that host our clients’ critical sites and services.

 

 

 



Silverlight 5 Hosting - ASPHostPortal :: Breakpoints on Xaml in Silverlight 5

clock May 14, 2012 09:53 by author Jervis

Silverlight 5 Beta brings the enormously useful ability to set a break point in your Xaml where you have a data binding. This can greatly simplify debugging and fixing binding issues.



To see this, create a new Silverlight 5 project and set up the Xaml to have 5 rows and 2 columns. Place the title in the first row (spanning both columns) and prompts in the next 4 rows. The prompts are


- Full name

- Address
- Phone
- Email

Add four TextBlocks in the second column to display the values that will correspond to these prompts. The Xaml for the four prompts looks like this:


<TextBlock
    Grid.Column="1"
    Grid.Row="1"
    Margin="5"
    HorizontalAlignment="Left"
    VerticalAlignment="Center"
    Text="{Binding FullName}" />
<TextBlock
    Grid.Column="1"
    Grid.Row="2"
    Margin="5"
    HorizontalAlignment="Left"
    VerticalAlignment="Center"
    Text="{Binding FullName}" />
<TextBlock
    Grid.Column="1"
    Grid.Row="2"
    Margin="5"
    HorizontalAlignment="Left"
    VerticalAlignment="Center"
    Text="{Binding Address}" />
<TextBlock
    Grid.Column="1"
    Grid.Row="4"
    Margin="5"
    HorizontalAlignment="Left"
    VerticalAlignment="Center"
    Text="{Binding PhoneNumber}" />
<TextBlock
    Grid.Column="1"
    Grid.Row="4"
    Margin="5"
    HorizontalAlignment="Left"
    VerticalAlignment="Center"
    Text="{Binding Email}" />

To make this work, of course, we need a class and an instance to bind to. Begin by creating a new class, Person,


public class Person
{
    public string FullName { get; set; }
    public string Address { get; set; }
    public string Phone { get; set; }
    public string Email { get; set; }
}

In MainPage.xaml.cs create an instance of Person, and set that instance to be the data context for the bindings,

public MainPage()
{
    InitializeComponent();
    var per = new Person()
    {
        FullName = "Jesse Liberty",
        Address = "100 Main Street, Boston, MA",
        Email = "[email protected]",
        Phone = "617-888-1243"
    };
    this.DataContext = per;
}

When you run this you’ll find that three of the four bindings work well, but the phone number is not displayed. Set a break point in the Xaml folder on the binding for the PhoneNumber and run the application. When you hit the break point examine the locals window as shown in the illustration to the right.



Note that there is an error message. By clicking on the message you can open a text reader for the entire error message, as shown in the next figure to the right.



The error message indicates that there is no property PhoneNumber in the type Person, and sure enough, a quick check of the code shows that the property is just Phone.

Change the binding from PhoneNumber to Phone and the program works as expected

 



ASP.NET MVC 3 Hosting - ASPHostPortal :: Set up custom error pages to handle errors in “non-AJAX” requests and jQuery AJAX requests

clock May 4, 2012 08:16 by author Jervis

In this blog post I will show how to set up custom error pages in ASP.NET MVC 3 applications to create user-friendly error messages instead of the (yellow) IIS default error pages for both “normal” (non-AJAX) requests and jQuery AJAX requests.

In this showcase we will implement custom error pages to handle the HTTP error codes 404 (“Not Found”) and 500 (“Internal server error”) which I think are the most common errors that could occur in web applications. In a first step we will set up the custom error pages to handle errors occurring in “normal” non-AJAX requests and in a second step we add a little JavaScript jQuery code that handles jQuery AJAX errors.

We start with a new (empty) ASP.NET MVC 3 project and activate custom errors in the Web.config by adding the following lines under <system.web>:

<customErrors
mode="On" defaultRedirect="/Error">
  <error redirect="/Error/NotFound" statusCode="404"/>
  <error redirect="/Error/InternalServerError" statusCode="500"/>
</customErrors>


Note: You can set
mode=Off” to disable custom errors which could be helpful while developing or debugging. Setting mode=RemoteOnly” activates custom errors only for remote clients, i.e. disables custom errors when accessing via http://localhost/[...]. In this example setting mode=”On” is fine since we want to test our custom errors. You can find more information about the <customErrors> element here.

In a next step we
remove the following line in Global.asax.cs file:

filters.Add(new HandleErrorAttribute());


and add a new
ErrorController (Controllers/ErrorController.cs):

public class ErrorController : Controller
{
  public ActionResult Index()
  {
    return InternalServerError();
  }

  public ActionResult NotFound()
  {
    Response.TrySkipIisCustomErrors = true;
    Response.StatusCode = (int)HttpStatusCode.NotFound;
    return View("NotFound");
  }

  public ActionResult InternalServerError()
  {
    Response.TrySkipIisCustomErrors = true;
    Response.StatusCode = (int)HttpStatusCode.InternalServerError;
    return View("InternalServerError");
  }
}

In a last step we add the ErrorController‘s views (Views/Error/NotFound.cshtml and Views/Error/InternalServerError.cshtml) that defines the (error) pages the end user will see in case of an error. The views include a partial view defined in Views/Shared/Error/NotFoundInfo.cshtml respectively Views/Shared/Error/InternalServerErrorInfo.cshtml that contains the concrete error messages. As we will see below using these partial views enables us to reuse the same error messages to handle AJAX errors.

Views/Error/NotFound.cshtml:
@{
  ViewBag.Title = "Not found";
}
@{
  Html.RenderPartial("Error/NotFoundInfo");
}

Views/Shared/Error/NotFoundInfo.cshtml:

The URL you have requested was not found.

Views/Error/InternalServerError.cshtml:

@{

  ViewBag.Title = "Internal server error";
}
@{
  Html.RenderPartial("Error/InternalServerErrorInfo");
}

Views/Shared/Error/InternalServerErrorInfo.cshtml:

An internal Server error occured.

To handle errors occurring in (jQuery) AJAX calls we will use jQuery UI to show a dialog containing the error messages. In order to include jQuery UI we need to add two lines to Views/Shared/_Layout.cshtml:

<link href="@Url.Content("~/Content/themes/base/jquery.ui.all.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.11.min.js")" type="text/javascript"></script>

Moreover we add the following jQuery JavaScript code (defining the global AJAX error handling) and the Razor snippet (defining the dialog containers) to Views/Shared/_Layout.cshtml:

<script type="text/javascript">
  $(function () {
    // Initialize dialogs ...
    var dialogOptions = {
      autoOpen: false,
      draggable: false,
      modal: true,
      resizable: false,
      title: "Error",
      closeOnEscape: false,
      open: function () { $(".ui-dialog-titlebar-close").hide(); }, // Hide close button
      buttons: [{
        text: "Close",
        click: function () { $(this).dialog("close"); }
      }]
    };
    $("#InternalServerErrorDialog").dialog(dialogOptions);
    $("#NotFoundInfoDialog").dialog(dialogOptions);

    // Set up AJAX error handling ...
    $(document).ajaxError(function (event, jqXHR, ajaxSettings, thrownError) {
      if (jqXHR.status == 404) {
        $("#NotFoundInfoDialog").dialog("open");
      } else if (jqXHR.status == 500) {
        $("#InternalServerErrorDialog").dialog("open");
      } else {
        alert("Something unexpected happend :( ...");
      }
    });
  });
</script>

<div id="NotFoundInfoDialog">
  @{ Html.RenderPartial("Error/NotFoundInfo"); }
</div>
<div id="InternalServerErrorDialog">
  @{ Html.RenderPartial("Error/InternalServerErrorInfo"); }
</div>

As you can see in the Razor snippet above we reuse the error texts defined in the partial views saved in Views/Shared/Error/.

To test our custom errors we define the HomeController (Controllers/HomeController.cs) as follows:

  public class HomeController : Controller
  {
  public ActionResult Index()
  {
    return View();
  }
  public ActionResult Error500()
  {
    throw new Exception();
  }
}


and the corresponding view
Views/Home/Index.cshtml:

@{

  ViewBag.Title = "ViewPage1";
}


<
script type="text/javascript">
  $function () {
    $("a.ajax").click(function (event) {
      event.preventDefault();
      $.ajax({
      url: $(this).attr('href'),
    });
  });
});

</
script>

<
ul>
  <li>@Html.ActionLink("Error 404 (Not Found)", "Error404")</li>
  <li>@Html.ActionLink("Error 404 (Not Found) [AJAX]", "Error404", new { }, new { Class = "ajax" })</li>
  <li>@Html.ActionLink("Error 500 (Internal Server Error)", "Error500")</li>
  <li>@Html.ActionLink("Error 500 (Internal Server Error) [AJAX]", "Error500", new { }, new { Class = "ajax" })</li>
</
ul>

To test the custom errors you can launch the project and click one of the four links defined in the view above. The “AJAX links” should open a dialog containing the error message and the “non-AJAX” links should redirect to a new page showing the same error message.


Summarized this blog post shows how to set up custom errors that handle errors occurring in both AJAX requests and “non-AJAX” requests. Depending on the project, one could customize the example code shown above to handle other HTTP errors as well or to show more customized error messages or dialogs.


Reasons why you must trust ASPHostPortal.com

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

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

- DELL Hardware
Dell hardware is engineered to keep critical enterprise applications running around the clock with clustered solutions fully tested and certified by Dell and other leading operating system and application providers.
- Recovery Systems
Recovery becomes easy and seamless with our fully managed backup services. We monitor your server to ensure your data is properly backed up and recoverable so when the time comes, you can easily repair or recover your data.

- Control Panel
We provide one of the most comprehensive customer control panels available. Providing maximum control and ease of use, our Control Panel serves as the central management point for your ASPHostPortal account. You’ll use a flexible, powerful hosting control panel that will give you direct control over your web hosting account. Our control panel and systems configuration is fully automated and this means your settings are configured automatically and instantly.

- Excellent Expertise in Technology
The reason we can provide you with a great amount of power, flexibility, and simplicity at such a discounted price is due to incredible efficiencies within our business. We have not just been providing hosting for many clients for years, we have also been researching, developing, and innovating every aspect of our operations, systems, procedures, strategy, management, and teams. Our operations are based on a continual improvement program where we review thousands of systems, operational and management metrics in real-time, to fine-tune every aspect of our operation and activities. We continually train and retrain all people in our teams. We provide all people in our teams with the time, space, and inspiration to research, understand, and explore the Internet in search of greater knowledge. We do this while providing you with the best hosting services for the lowest possible price.

- Data Center

ASPHostPortal modular Tier-3 data center was specifically designed to be a world-class web hosting facility totally dedicated to uncompromised performance and security
- Monitoring Services
From the moment your server is connected to our network it is monitored for connectivity, disk, memory and CPU utilization – as well as hardware failures. Our engineers are alerted to potential issues before they become critical.

- Network
ASPHostPortal has architected its network like no other hosting company. Every facet of our network infrastructure scales to gigabit speeds with no single point of failure.

- Security
Network security and the security of your server are ASPHostPortal’s top priorities. Our security team is constantly monitoring the entire network for unusual or suspicious behavior so that when it is detected we can address the issue before our network or your server is affected.

- Support Services
Engineers staff our data center 24 hours a day, 7 days a week, 365 days a year to manage the network infrastructure and oversee top-of-the-line servers that host our clients’ critical sites and services.

 



Visual Studio LightSwitch Hosting - ASPHostPortal :: How to Add URL in Navigation Menu in Visual Studio LightSwitch 2011

clock May 2, 2012 08:25 by author Jervis

As you probably know, Visual Studio LightSwitch is a tool provided by Microsoft to build business applications. In this article you will see how to add an URL to the navigation menu of a LightSwitch application.

An URL is a Uniform Resource Locator, it is also known as a web address. When we want to open a website then we write a web address in the address bar in the internet browser. If you want to add any URL in your LightSwitch navigation menu then you can do that.


Step 1
: First of all open Visual Studio LightSwitch->Click on new project->Select LightSwitch->Select LightSwitch application->Write name (AddUrl)->Ok.



Step 2
: Right-click on screens->Add screen.



Step 3
: Select new data screen->Write screen name (UrlInNavigation)->Select screen data (None)->Ok.



Step 4
: Go to Solution Explorer->Click on file view.



Step 5
: Right-click on client->Add references.



Step 6
: Select System.Windows.Browser->Ok.



Step 7
: Expand write code->Select UrlInNavigation_Run->Write code.



Code

using
System;
using System.Linq;
using System.IO;
using System.IO.IsolatedStorage;
using System.Collections.Generic;
using Microsoft.LightSwitch;
using Microsoft.LightSwitch.Framework.Client;
using Microsoft.LightSwitch.Presentation;
using Microsoft.LightSwitch.Presentation.Extensions;
using System.Runtime.InteropServices.Automation;
using System.Windows.Browser;
using Microsoft.LightSwitch.Client;
using Microsoft.LightSwitch.Threading;
namespace LightSwitchApplication
{
   public partial class Application
  
{
     partial void UrlInNavigation_Run(ref bool handled)
     {
        // Set handled to 'true' to stop further processing.
       
var uri = new Uri("http://www.windows2008hosting.asphostportal.com/", UriKind.RelativeOrAbsolute);
        Dispatchers.Main.BeginInvoke(() =>
        {
             if (AutomationFactory.IsAvailable)
             {
                 var shell = AutomationFactory.CreateObject("Shell.Application");
                 shell.ShellExecute(uri.ToString());
             }
             else
            
{
                 throw new InvalidOperationException();
             }
        });
     }
   }
}

Step 8 : Go to Solution Explorer->Click on logical view.

Step 9 : Right click on screens->Select edit screen navigation

Step 10 : Select UrlInNavigation->Clear->Set.

Step 11 : Run the application (Press F5).

 

 



ASPHostPortal Announces SQL Server 2012 Support

clock May 1, 2012 08:44 by author Jervis

ASPHostPortal is a premiere web hosting company that specialized in Windows and ASP.NET-based hosting, announces the deployment of SQL Server 2012 in its web hosting packages. The SQL Server 2012 is brand new database management software from Microsoft that provides robust solutions for businesses to organize and secure company's data in one large-scale framework.

One of the most powerful and recognized SQL database engines available, Microsoft SQL Server provides many different levels of functionality and feature sets, and the latest release includes greater uptime, enhanced query performance, and improved security features. Also included is the new ‘Business Intelligence’ version of the product, and a more scaled-down ‘Express’ version, featuring the new ‘LocalDB’ functionality.


"I am very proud today, as we again have been able to exceed expectations by being able to offer this latest version of SQL Server to our customers so quickly after its official release," said Robert Kruger, CEO of ASPHostPortal.com. "We continue to offer significant added value to Microsoft products. We prove our existence in this business."


ASPHostPortal offers hosting packages bundle with the SQL Server 2012, including ASP.NET hosting and also our Reseller Hosting. This is to ensure that its customers can always have the latest technology included in their account. Businesses with all of important data from each department need a framework to manage and secure all of that data. And it can be achieved by implementing the SQL Server 2012. This robust data warehouse development merges everything together and makes sure there is no leakage. SQL Server 2012 keeps every data on its place and works as its best.
 

For more information about this new product, please visit our site at
http://asphostportal.com/Cheap-SQL-2012-Hosting.aspx.

About ASPHostPortal:

We’re a company that works differently to most. Value is what we output and help our customers achieve, not how much money we put in the bank. It’s not because we are altruistic. It’s based on an even simpler principle. "Do good things, and good things will come to you".



Silverlight 5 Hosting - ASPHostPortal :: PivotViewer Custom DetailPaneStyle in Silverlight 5

clock April 24, 2012 07:08 by author Jervis

One of the added API features of the new Silverlight 5 PivotViewer is the ability to define a custom detail pane. It is rather simple to replace the style with your own, however, then you are left with the task of implementing several features that you most likely want to keep (like when to show and hide your detail pane). There are also a few other states and navigation features that would also be nice to keep. We will look at how you can replace the default implementation with the smallest amount of code and keep the functionality that you will want to keep.

In order to keep from reinventing the wheel when implementing our new detail pane, we are going to start off with the
PivotViewerDetailPane control. This is the control that is being used in the default implementation. By using our own instance of the control, we are able to take advantage of all of that hard work the PivotViewer team has done for us.

The first thing we need to do is see how to implement our own copy of the control. You can override the default implementation by setting the DetailPaneStyle property on the PivotViewer. Here is what an example would look like :


<pivot:PivotViewer x:Name="pViewer">
    <pivot:PivotViewer.DetailPaneStyle>
        <Style TargetType="pivot:PivotViewerDetailPane">
        </Style>
    </pivot:PivotViewer.DetailPaneStyle>
</pivot:PivotViewer>


This simply sets the
DetailPaneStyle to a basic implementation of the PivotViewerDetailPane. However, if we run our example, we soon see that it is close, but not quite the default we are looking for. Now the good news is that we have proved to we have overridden the default.



With a bit more research, you will see that you need to set some default colors. Here are the colors that are originally set:


<
pivot:PivotViewer.DetailPaneStyle>
    <Style TargetType="pivot:PivotViewerDetailPane">
        <Setter Property="Foreground"
                Value="{Binding Foreground,
                RelativeSource={RelativeSource Mode=FindAncestor,
                AncestorType=pivot:PivotViewer}}"
/>
        <Setter Property="Background"
                Value="{Binding Background,
                RelativeSource={RelativeSource Mode=FindAncestor,
                AncestorType=pivot:PivotViewer}}"
/>
        <Setter Property="BorderBrush"
                Value="{Binding BorderBrush,
                RelativeSource={RelativeSource Mode=FindAncestor,
                AncestorType=pivot:PivotViewer}}"
/>
        <Setter Property="AccentColor"
                Value="{Binding AccentColor,
                RelativeSource={RelativeSource Mode=FindAncestor,
                AncestorType=pivot:PivotViewer}}"
/>
        <Setter Property="Background"
                Value="{Binding SecondaryBackground,
                RelativeSource={RelativeSource Mode=FindAncestor,
                AncestorType=pivot:PivotViewer}}"
/>
        <Setter Property="ControlBackground"
                Value="{Binding ControlBackground,
                RelativeSource={RelativeSource Mode=FindAncestor,
                AncestorType=pivot:PivotViewer}}"
/>
        <Setter Property="SecondaryForeground"
                Value="{Binding SecondaryForeground,
                RelativeSource={RelativeSource Mode=FindAncestor,
                AncestorType=pivot:PivotViewer}}"
/>
        <Setter Property="PrimaryItemValueBackgroundColor"
                Value="{Binding PrimaryItemValueBackgroundColor,
                RelativeSource={RelativeSource Mode=FindAncestor,
                AncestorType=pivot:PivotViewer}}"
/>
        <Setter Property="SecondaryItemValueBackgroundColor"
                Value="{Binding SecondaryItemValueBackgroundColor,
                RelativeSource={RelativeSource Mode=FindAncestor,
                AncestorType=pivot:PivotViewer}}"
/>
    </Style>
</pivot:PivotViewer.DetailPaneStyle>


As you can see, the detail pane is using the new Silverlight 5 Feature RelativeSource binding to carry the theme colors of the PivotViewer to the detail pane. Obviously, this gives you an opportunity to create your own custom colors if you so choose. If not, it gets us back to the starting point.




Now that we are at a good starting point, let’s figure out what we want to modify. Most of the people I have talked to are only interested in modifying the contents of the detail pane itself and not the entire shell. So we will focus this discussion on the modifying the
ContentTemlate of the PivotViewerDetailPane.



When you replace the
ContentTemplate there are a couple of things you need to remember. The first is the default width of the original template is 190px. The detail pane will grow to accommodate any size that you need, but that is what the default is. The other thing to remember is a bit tricky, and that is the visibility of the contents. If you do not collapse your container by default, then it will be visible while the PivotViewer is loading. It causes a weird user experience and should be handled. We can handle that with a multi-part binding. First we bind the Visibility to the IsShowing property of the PivotViewerDetailPane. We have to write a value converter to change the bool IsShowing to a Visibility. If you haven’t had to do that before, it’s a handy little converter to keep in your toolkit.

public class BoolToVisibilityConverter : IValueConverter
{

    public object Convert(object value,
        Type targetType,
        object parameter,
        System.Globalization.CultureInfo culture)
    {
        if(value is bool)
        {
            return (bool) value ?
                    Visibility.Visible :
                    Visibility.Collapsed;
        }

        return Visibility.Collapsed;
    }

    public object ConvertBack(object value,
        Type targetType,
        object parameter,
        System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}


Now you are able to set up your custom detail pane. Here is very simple example using a dummy data set that has a
Color property in it. We are replacing the default content with an Ellipse that is filled with the Color property of our object.

<Setter Property="ContentTemplate">
    <Setter.Value>
        <DataTemplate>
            <Grid Width="190"
                Visibility="{Binding IsShowing,
                RelativeSource={RelativeSource
                AncestorType=pivot:PivotViewerDetailPane},
                Converter={StaticResource boolConv},
                FallbackValue=Collapsed}">
                <Ellipse Width="100" Height="100"
                         Fill="{Binding Color}"
                         VerticalAlignment="Top"
                         Margin="0,30,0,0"/>
            </Grid>
        </DataTemplate>
    </Setter.Value>

</Setter>




Obviously this is a rather simplistic detail pane, so feel free to make yours a bit more complex and interesting.


Get Silverlight 5 Hosting with only $2.00/month at ASPHostPortal.com.



ASP.NET MVC 3 Hosting - ASPHostPortal :: User Activity logging in ASP.NET MVC app using Action Filter and log4net

clock April 6, 2012 07:59 by author Jervis

In this post, I will demonstrate how to use an action filter to log user tracking information in an ASP.NET MVC app. The below action filter will take logged user name, controller name, action name, timestamp information and the value of route data id. These user tracking information will be logged using log4net logging framework.

public class UserTrackerAttribute : ActionFilterAttribute, IActionFilter

{         


    public override void OnActionExecuted(ActionExecutedContext filterContext)
    {
        var actionDescriptor= filterContext.ActionDescriptor;
        string controllerName = actionDescriptor.ControllerDescriptor.ControllerName;
        string actionName = actionDescriptor.ActionName;
        string userName = filterContext.HttpContext.User.Identity.Name.ToString();
        DateTime timeStamp = filterContext.HttpContext.Timestamp;
        string routeId=string.Empty;
        if (filterContext.RouteData.Values["id"] != null)
        {
            routeId = filterContext.RouteData.Values["id"].ToString();
        }
        StringBuilder message = new StringBuilder();
        message.Append("UserName=");
        message.Append(userName + "|");
        message.Append("Controller=");
        message.Append(controllerName+"|");
        message.Append("Action=");
        message.Append(actionName + "|");
        message.Append("TimeStamp=");
        message.Append(timeStamp.ToString() + "|");
        if (!string.IsNullOrEmpty(routeId))
        {
            message.Append("RouteId=");
            message.Append(routeId);
        }
        var log=ServiceLocator.Current.GetInstance<ILoggingService>();
        log.Log(message.ToString());
        base.OnActionExecuted(filterContext);
    }
}

The LoggingService class is given below


public class LoggingService : ILoggingService

    {
        private static readonly ILog log = LogManager.GetLogger
            (MethodBase.GetCurrentMethod().DeclaringType);
        public void Log(string message)
        {
            log.Info(message);
        }
    }
    public interface ILoggingService
    {
        void Log(string message);
    }

The LoggingService class is using log4net framework for logging. You can add reference to log4net using
NuGet.

The following command on NuGet console will install log4net into your ASP.NET MVC app.

PM> install-package Log4Net

The below configuration information in web.config will configure log4net for using with Sql Server

Let me add a log4net section to the <configSections> of web.config

<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net"/>

The below is the log4net section in the web.config file

<log4net>
    <root>
      <level value="ALL"/>
      <appender-ref ref="ADONetAppender"/>
    </root>
    <appender name="ADONetAppender" type="log4net.Appender.AdoNetAppender">
      <connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      <connectionString value="data source=.\SQLEXPRESS;Database=MyFinance;Trusted_Connection=true;" />
      <commandText value="INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message]) VALUES (@log_date, @thread, @log_level, @logger, @message)" />
      <parameter>
        <parameterName value="@log_date" />
        <dbType value="DateTime" />
        <layout type="log4net.Layout.PatternLayout" value="%date{yyyy'-'MM'-'dd HH':'mm':'ss'.'fff}" />
      </parameter>
      <parameter>
        <parameterName value="@thread" />
        <dbType value="String" />
        <size value="255" />
        <layout type="log4net.Layout.PatternLayout" value="%thread" />
      </parameter>
      <parameter>
        <parameterName value="@log_level" />
        <dbType value="String" />
        <size value="50" />
        <layout type="log4net.Layout.PatternLayout" value="%level" />
      </parameter>
      <parameter>
        <parameterName value="@logger" />
        <dbType value="String" />
        <size value="255" />
        <layout type="log4net.Layout.PatternLayout" value="%logger" />
      </parameter>
      <parameter>
        <parameterName value="@message" />
        <dbType value="String" />
        <size value="4000" />
        <layout type="log4net.Layout.PatternLayout" value="%message" />
      </parameter>
    </appender>
  </log4net>


Configure log4net

The below code in the Application_Start() of Global.asax.cs will configure the log4net

log4net.Config.XmlConfigurator.Configure();


The below Sql script is used for creating table in Sql Server for logging information

CREATE TABLE [dbo].[Log] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[Date] [datetime] NOT NULL ,
[Thread] [varchar] (255) NOT NULL ,
[Level] [varchar] (20) NOT NULL ,
[Logger] [varchar] (255) NOT NULL ,
[Message] [varchar] (4000) NOT NULL
) ON [PRIMARY]

 



ASP.NET MVC 3 Hosting - ASPHostPortal :: ASP.NET MVC 3 Routing

clock March 15, 2012 07:52 by author Jervis

Routing in an ASP.NET module is responsible for mapping incoming browser requests to a particular MVC controller action.

When Requests arrive to an ASP.NET MVC-based web application it actually first passes through the UrlRoutingModule object, which is an HTTP module.


This module parses the request; i.e. the request from the URL and performs route selection. The UrlRoutingModule object selects the first route object that matches the current request.


If no routes match, the UrlRoutingModule object does nothing and lets the request fall back to the regular ASP.NET or IIS request processing.


Now From the selected Route object, the UrlRoutingModule object contains the IRouteHandler object that is associated with the Route object. This is an instance of MvcRouteHandler. The IRouteHandler instance creates an IHttpHandler object that passes it the IHttpContext object. By default, the IHttpHandler instance for MVC is the MvcHandler object. The MvcHandler object then selects the controller that will ultimately handle the request.


See when an ASP.NET MVC web application runs in IIS 7.0, no file name extension is required for MVC projects. So you cannot find the .aspx,.ascx,.asmx extension.


Now when you create a new ASP.NET MVC application, it will automatically configure to use ASP.NET Routing. ASP.NET Routing is set up in two places:


1. Webconfig File

2. Global.asax file

Now interestingly when you create a MVC2 application a route table is automatically created in the application's Global.asax file.


As we all know the Global.asax contains event handlers for ASP.NET application lifecycle events. The route table is created during the Application Start event. So when you open the Global.asax file you will see the following code:


using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.Mvc;

using System.Web.Routing;

namespace MvcApplication1

{

// Note: For instructions on enabling IIS6 or IIS7 classic mode,

// visit http://go.microsoft.com/?LinkId=9394801

public class MvcApplication : System.Web.HttpApplication

{

public static void RegisterRoutes(RouteCollection routes)

{

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

routes.MapRoute(

"Default", // Route name

"{controller}/{action}/{id}", // URL with parameters

new { controller = "Home", action = "Index", id = "" } // Parameter defaults

);

}

protected void Application_Start()

{

RegisterRoutes(RouteTable.Routes);

}

}

}


See here the routing is occuring in the "RegisterRoutes" method.


See in the routes.MapRoute method we are passing 3 parameters.


1. Controller(Name of the controller)

2. Action (The method inside the controller)
3. id (Parameter)

See in the above url before home it is domain. The home is control. The action method is the index with parameter id. Now in the home controller the code will be:


using System.Web.Mvc;

namespace MvcApplication1.Controllers

{

public class HomeController : Controller

{

public ActionResult Index(int id)

{

return View();

}

}

}


Conclusion:
So in this article we have seen what the functionality of routing in ASP.Net MVC 3 is.

Reasons why you must trust ASPHostPortal.com

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

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

- DELL Hardware
Dell hardware is engineered to keep critical enterprise applications running around the clock with clustered solutions fully tested and certified by Dell and other leading operating system and application providers.
- Recovery Systems
Recovery becomes easy and seamless with our fully managed backup services. We monitor your server to ensure your data is properly backed up and recoverable so when the time comes, you can easily repair or recover your data.

- Control Panel
We provide one of the most comprehensive customer control panels available. Providing maximum control and ease of use, our Control Panel serves as the central management point for your ASPHostPortal account. You’ll use a flexible, powerful hosting control panel that will give you direct control over your web hosting account. Our control panel and systems configuration is fully automated and this means your settings are configured automatically and instantly.

- Excellent Expertise in Technology
The reason we can provide you with a great amount of power, flexibility, and simplicity at such a discounted price is due to incredible efficiencies within our business. We have not just been providing hosting for many clients for years, we have also been researching, developing, and innovating every aspect of our operations, systems, procedures, strategy, management, and teams. Our operations are based on a continual improvement program where we review thousands of systems, operational and management metrics in real-time, to fine-tune every aspect of our operation and activities. We continually train and retrain all people in our teams. We provide all people in our teams with the time, space, and inspiration to research, understand, and explore the Internet in search of greater knowledge. We do this while providing you with the best hosting services for the lowest possible price.

- Data Center

ASPHostPortal modular Tier-3 data center was specifically designed to be a world-class web hosting facility totally dedicated to uncompromised performance and security
- Monitoring Services
From the moment your server is connected to our network it is monitored for connectivity, disk, memory and CPU utilization – as well as hardware failures. Our engineers are alerted to potential issues before they become critical.

- Network
ASPHostPortal has architected its network like no other hosting company. Every facet of our network infrastructure scales to gigabit speeds with no single point of failure.

- Security
Network security and the security of your server are ASPHostPortal’s top priorities. Our security team is constantly monitoring the entire network for unusual or suspicious behavior so that when it is detected we can address the issue before our network or your server is affected.

- Support Services
Engineers staff our data center 24 hours a day, 7 days a week, 365 days a year to manage the network infrastructure and oversee top-of-the-line servers that host our clients’ critical sites and services.



WebMatrix Hosting - ASPHostPortal :: New Features WebMatrix 2 Beta

clock March 9, 2012 07:04 by author Administrator

There are bunch of NEW features in WebMatrix 2 Beta on top of WebMatrix 1, but I wanted to just call out few top items:

- Even more seamless and awesome integration with
Application Gallery where now you will not have to fill in the standard application installation parameters

- OSS Application specific code completion which means users of popular apps like WordPress can get help customized to their applications


- Custom look and feel for each Web Application which means if you are editing Umbraco you will feel like WebMatrix is designed for Umbraco with specific contextual actions called out by application authors.


- Intlellisense for HTML, CSS, JS, C#, VB, ASP.NET Razor as well as PHP.


- Support for HTML5, CSS3 as well as jQuery constructs.


- New awesome tools like color picker.


- Completely revamped Database workspace where you can now execute multiple queries.


- Extensibility support by which you can write your own extension for WebMatrix.  And trust me it is so easy that you can whip out a ribbon button to do something cool just within minutes.


- NuGet integration to allow you to build your app with community by your side.


- Remote tools which will allow you to see the server files and even edit them within seconds.


- Integrated learning experience with learnable, pluralsight and appendto


- And more and more…


You can read all about it at
http://webmatrix.com/next

Reasons why you must trust ASPHostPortal.com

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

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

- DELL Hardware
Dell hardware is engineered to keep critical enterprise applications running around the clock with clustered solutions fully tested and certified by Dell and other leading operating system and application providers.
- Recovery Systems
Recovery becomes easy and seamless with our fully managed backup services. We monitor your server to ensure your data is properly backed up and recoverable so when the time comes, you can easily repair or recover your data.

- Control Panel
We provide one of the most comprehensive customer control panels available. Providing maximum control and ease of use, our Control Panel serves as the central management point for your ASPHostPortal account. You’ll use a flexible, powerful hosting control panel that will give you direct control over your web hosting account. Our control panel and systems configuration is fully automated and this means your settings are configured automatically and instantly.

- Excellent Expertise in Technology
The reason we can provide you with a great amount of power, flexibility, and simplicity at such a discounted price is due to incredible efficiencies within our business. We have not just been providing hosting for many clients for years, we have also been researching, developing, and innovating every aspect of our operations, systems, procedures, strategy, management, and teams. Our operations are based on a continual improvement program where we review thousands of systems, operational and management metrics in real-time, to fine-tune every aspect of our operation and activities. We continually train and retrain all people in our teams. We provide all people in our teams with the time, space, and inspiration to research, understand, and explore the Internet in search of greater knowledge. We do this while providing you with the best hosting services for the lowest possible price.

- Data Center

ASPHostPortal modular Tier-3 data center was specifically designed to be a world-class web hosting facility totally dedicated to uncompromised performance and security
- Monitoring Services
From the moment your server is connected to our network it is monitored for connectivity, disk, memory and CPU utilization – as well as hardware failures. Our engineers are alerted to potential issues before they become critical.

- Network
ASPHostPortal has architected its network like no other hosting company. Every facet of our network infrastructure scales to gigabit speeds with no single point of failure.

- Security
Network security and the security of your server are ASPHostPortal’s top priorities. Our security team is constantly monitoring the entire network for unusual or suspicious behavior so that when it is detected we can address the issue before our network or your server is affected.

- Support Services
Engineers staff our data center 24 hours a day, 7 days a week, 365 days a year to manage the network infrastructure and oversee top-of-the-line servers that host our clients’ critical sites and services.

 



About ASPHostPortal.com

We’re a company that works differently to most. Value is what we output and help our customers achieve, not how much money we put in the bank. It’s not because we are altruistic. It’s based on an even simpler principle. "Do good things, and good things will come to you".

Success for us is something that is continually experienced, not something that is reached. For us it is all about the experience – more than the journey. Life is a continual experience. We see the Internet as being an incredible amplifier to the experience of life for all of us. It can help humanity come together to explode in knowledge exploration and discussion. It is continual enlightenment of new ideas, experiences, and passions

 photo ahp banner aspnet-01_zps87l92lcl.png

Author Link

Corporate Address (Location)

ASPHostPortal
170 W 56th Street, Suite 121
New York, NY 10019
United States

Sign in