Windows 2012 Hosting - MVC 6 and SQL 2014 BLOG

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

Top 5 Features of ASP.NET MVC Framework 4

clock April 12, 2013 12:27 by author Ben

ASP.NET MVC framework is designed to create web applications which can be accessed over the URLs like RESTful services. The application layers will clearly be segregated into Views, Models and Controllers. ASP.NET MVC Framework 4 is available as a separate installer for Visual Studio 2010 and comes out of the box with Visual Studio 2012. In this article I will explain my top 5 features or improvements in ASP.NET MVC 4 framework.

1. New Project Templates

There are a couple of new project templates added for ASP.NET MVC Framework version 4 named web API template and mobile application template. In the RC version of the product there was another template called Single Page Application (SPA) template but it was removed during the RTM.

Web API
Web API templates are used to create HTTP services. These HTTP services can be accessed directly by a variety of clients from tablets, and smart phones to normal PC browsers. It also helps the developers to implement RESTFul architecture in an MVC application. This template is a powerful tool since it paves an easy way for developers to create HTTP services utilizing the core ASP.NET MVC capabilities like Routing, Filters, Query composition, etc.

Mobile Application
As usage of the internet over mobile devices is becoming high, most companies started developing mobile specific applications. Microsoft has wisely included the mobile application template, which will support developing a pure mobile ASP.NET MVC web application. It will include the HTML helpers for mobile specific markups, and mobile specific plug-ins like jQuery mobile, etc.

2. Adaptive Rendering - ViewPort Tag & @media CSS

The ViewPort is a <meta> tag added to the client razor view, which will ensure that the page content is displayed in an optimum way despite if the client is a mobile device or a desktop. Without the ViewPort <meta> tag the same web page will be displayed on a mobile device as that of the desktop whereas the mobile device has a smaller screen than a desktop. It makes the usability of the application difficult on the mobile device. The below mentioned ViewPort tag solves this problem.

<meta name="viewport" content="width=device-width" />


The ViewPort tag does content resizing only at the page level. If the developer wants to customize each control styling based on the client device then the @media CSS tag can be used. It applies / overrides the CSS based on the size of the client screen.

   @media only screen and (max-width: 650 px)    
    {   
           /*CSS in this section will be applied when the request is made by a device with a screen and the width is less than 650 pixels*/    
           /*Custom CSS*/    
    }

3. Display Modes

This feature enables the developers to have different sets of views for each device and load them based on who is accessing the web application. This is required when the requirement is to change the view, content, control look or the operations different from device to device.
In order to have the display modes working, the razor views should be named as _Layout.mobile.cshtml and _Layout.cshtml. The idea is to load the former template view when accessed from a mobile device and to load the later one when accessed from a desktop. In the global.asax Application_Start event add the code below and MVC 4 takes care of doing it automatically.

 DefaultDisplayMode mobileDisplayMode = new DefaultDisplayMode("mobile")
                {
                    ContextCondition = (context => context.Request.Browser.IsMobileDevice)
                };

 DisplayModeProvider.Instance.Modes.Insert(0, mobileDisplayMode);

4. Support for Async Controller Actions

The Asp.Net MVC 4 application developed on .net framework 4.5 will support asynchronous action methods. An asynchronous controller action method will return a Task of ActionResult and will use async / await keywords. Below is a sample async action method.

namespace MvcApplication1.Controllers
    {
         public class HomeController : Controller
        {
     //Asynchronous Action Method of the controller
            public async Task<ActionResult> GreetAsync()
            {
                return View(await GetGreetMessageAync());
            }
            private async Task<string> GetGreetMessageAync()
            {
                string greetingText = String.Empty;
                await Task.Run(() =>
                    {
                        greetingText = "Welcome to async MVC action method demo";
                    });
                return greetingText;
            }
        }
    }

5. App_Start Folder

Another improvement, which I see with respect to the ASP.NET MVC solution architecture, is the introduction of App_Start folder, which helps in grouping all the code that is used for configuring the behavior of the Asp.Net MVC framework application. In the earlier versions on ASP.NET MVC all the configurations were directly done inside the global.ascx. Below are few of the config files that are added to the folder by default in an internet application template.

a.  AuthConfig.cs
b. BundleConfig.cs
c.  FilterConfig.cs
d. RouteConfig.cs
e. WebApiConfig.cs

ASP.NET MVC 4 also has lot of other features like the OAuth, bundling & minification, etc.



ASP.NET MVC 4 Hosting - ASPHostPortal :: Multiple Views and DisplayMode Providers in ASP.NET MVC 4

clock April 8, 2013 12:35 by author Jervis

All in all, the biggest difference between ASP.NET MVC and ASP.NET Web Forms is the neat separation that exists in ASP.NET MVC between the actions that follows a request and the generation of the subsequent response for the browser.

The request lifecycle In Web Forms was a continuous flow. Firstly, a Page object was created from default settings hard-coded in the ASPX file and then initialized to the last known good state read from the viewstate field. The user code had then a chance to further update the state of the Page object before the postback event was handled and the state of the page to render back to the user was prepared.

All this happened in a single procedure: There was little chance for developers to serve different views in front of the same request. On the other hand, Web Forms is built around the concept of a “page”. If you request a page, you’re going to get “that” page. Subsequently, if you request default.aspx from a site intended for desktop use why should you be expecting to receive a mobile optimized page instead if you’re making the request from a mobile device? If you want a mobile page, you just set up a new mobile site and make it reachable through a different URL. At that point, you have a distinct “page” to invoke and it all works as expected.

Web Forms at some point was also extended with convention-based tricks to automatically serve different master pages to different browsers and also to make server controls capable of returning different values for different browsers. Nevertheless, Web Forms serves the vision of the web world that was mainstream more than a decade ago. Unless you have serious backward compatibility reasons, you should definitely consider making the step forward to ASP.NET MVC; and use ASP.NET MVC for any new development.

Anyway, this article is NOT about the endless debate the relative merits of Web Forms and MVC—there’s really nothing to discuss there. This article is about new features introduced in ASP.NET MVC 4 to make it really easy and effective to serve different views in front of the same request.

Display Modes

Here’s the classic example where display modes fit in. Suppose you have a Home controller with an Index method.

public class HomeController : Controller
{
    public ActionResult Index()
    {
        return View();
    }
}

As you know, you should also have a file named index.cshtml located under the Views/Home folder in the project. This file will provide the HTML for the browser. In the body of the Index method above you code (or better, you invoke from other components) the logic required to serve the request. If, by executing this piece of logic, data is produced which needs to be embedded in the view, then you pass this data down to the view object by adding an argument to the View method.

public class HomeController : Controller
{
    public ActionResult Index()
    {
        var model = ProcessRequestAndGetData();
        return View(model);
    }
}

So far so good.

Now in ASP.NET MVC 4 there’s an extra piece of magic that you might not know about yet. To experience the thrill of it, you add a new file to the Views/Home folder named index.mobile.cshtml. You can give this file any content you like; just make sure the content is different from the aforementioned index.cshtml.

Now launch the sample site and visit it with both a regular desktop browser, Internet Explorer perhaps, and a mobile browser. You can use the Windows Phone emulator or perhaps Opera Emulator. However, the simplest thing you can do to test the feature without much pain is to hit F12 and bring up the IE Developer’s Tools window. From there, you set a fake user agent that matches a mobile device. If you are clueless about what to enter, here’s a suggestion that matches an iPhone running iPhone OS 6:

Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko)

Quite surprisingly, the view you get for the same home/index URL is the mobile view as coded in the file index.mobile.cshtml.

What the heck is going on? Is this pure magic?

Even though I’m a firm believer that there can’t be any magic in software, well, I faced some terrible doubts until I found out about display modes.

Display Modes: Where Are Them?

To spot where display modes are and the role they play, I then used .NET Reflector to statically track the code path starting with the View method on the Controller class. From the View method, the code flow reaches the selected view engine—the RazorViewEngineclass in all cases in which CSHTML views are used. In ASP.NET MVC 4 all standard view engines inherit from the same base class—VirtualPathProviderViewEngine. This class has a new protected property named DisplayModeProvider. This property is of typeDisplayModeProvider. TheVirtualPathProviderViewEngine lists some helper methods through which the view name is resolved. The view engine receives the view name as set at the controller level: it can be name like “index” or it can be the empty string, as in the example above. If no view name is provided the view engine assumes it is the name of the action.

In ASP.NET MVC 4, an extra step takes place in theVirtualPathProviderViewEngine base class from which both WebFormsViewEngine and RazorViewEngine inherit. During the resolution of the view name, the view engine queries theDisplayModeProvider object to see if any of the registered display modes can be applied to the requested view. If a match is found, then the original view name is changed to point to the CSHTML file that represents the match. So, for instance, it may happen that “index” becomes “index.mobile”.

Let’s now explore further the internals of the DisplayModeProvider class.

The DisplayModeProvider Class

The documentation refers to this class as being internal to the framework; however, it has a few public members that you might, and should, be using in order to extend your site with multiple ad hoc views. The class has a static constructor that .NET Reflector decompiles as below:

static DisplayModeProvider()
{
    MobileDisplayModeId = "Mobile";
    DefaultDisplayModeId = string.Empty;
    _displayModeKey = new object();
    _instance = new DisplayModeProvider();
}

And here’s the constructor instead:

internal DisplayModeProvider()
{
    List list = new List();
    DefaultDisplayMode mode = new DefaultDisplayMode(MobileDisplayModeId) {
        ContextCondition = context => context.GetOverriddenBrowser().IsMobileDevice
    };
    list.Add(mode);
    list.Add(new DefaultDisplayMode());
    this._displayModes = list;
}

It turns out that DisplayModeProvider holds a list of DefaultDisplayMode objects each representing a display mode. By default, the provider holds two display modes: default and mobile. The default display mode is characterized by the empty string; the mobile display mode is characterized by the “mobile” string. These strings basically identify the suffix appended to the view name. This is where file name index.mobile.cshtml comes from.

It is interesting to focus on the following code:

DefaultDisplayMode mode = new DefaultDisplayMode(MobileDisplayModeId) {
     ContextCondition = context =>
context.GetOverriddenBrowser().IsMobileDevice
};

In spite of a misleading name, the DefaultDisplayMode class is just the official class that represents a display mode. As I see things, the “Default” prefix in the name is just out of place. A display mode class is built around two main pieces of information: suffix name and matching rule. In the code snippet above, a new display mode class is created with the suffix of “mobile”—the actual value of the MobileDisplayModeIdfield—and a matching rule assigned to the ContextConditionproperty. Property ContextCondition is a delegate as below:

Func<HttpContextBase, Boolean>

The purpose of the delegate is to analyze the HTTP context of the current request and return a Boolean answer to the question: should this display mode be used to serve the current request? How the Boolean response is found is entirely up to the implementation. As defined above, the mobile display mode parses the user agent string that comes with the request and seeks to find known keywords that would mark it for that of a mobile device. I’ll return on this point in a moment.

Listing Current Display Modes

You hardly have the need to do this in code, but I encourage you to try that out for pure fun. Here’s the code that reads and displays the currently available modes:

<ul>
    @{
        foreach(var d in DisplayModeProvider.Instance.Modes)
        {
            <li>@(String.IsNullOrEmpty(d.DisplayModeId) ?"default" :d.DisplayModeId)</li>
        }
    }
</ul>

You use the Instance static member to access the singleton instance of the DisplayModeProvider class and flip through the Modes property. By the way, the getter of the Modes property just returns the value stored in the internal _displayModes field dissected earlier through .NET Reflector.

Beyond the Default Configuration

The default and mobile display modes come free out of the box, but honestly they are not worth the cost. I have two reasons to say this. First, modern web sites need more than just a mobile/desktop dichotomy for views. You might want to distinguish tablets, smartphones, legacy phones, perhaps smart TVs. Sometimes this can be achieved with CSS media queries; sometimes you need to do server-side detection of the device via its provided user agent string. This leads to the second reason I have to blissfully ignore the default ASP.NET MVC configuration. Even if a plain desktop/mobile dichotomy works for your site, the point is that the logic behind the mobile context condition is weak and flaky. It has good chances to work with iPhone and BlackBerry devices; it may not even work with Windows Phone and Android devices—let alone with older and simpler devices. The method IsMobileDevice you have seen referenced a while back does sniffing of the user agent string based on the information it can find in the following .browser files you get installed with ASP.NET.

The model is clearly extensible and you can add more information at any time; but writing a .browser file may not be easy and the burden of testing, checking, and further extending the database is entirely on your shoulders.

The figure proves that I added a fairly large (18 MB) browser file—an XML file actually—named mobile.browser. That file comes from an old Microsoft project now discontinued and contains a reasonable amount of devices as of summer of 2011. All devices and browsers which came next are not correctly detected.

In the end, display modes are an excellent piece of infrastructure but require a bit of work on your end for configuration and additional tools to do view routing work effectively. The siren call about ASP.NET MVC being fully mobile aware is just a siren call.

What Can You Do About It?

You use display modes to give your site multiple views in front of the same URL. More concretely, this mostly means using defining a display mode for each device, or class of devices, you’re interested in. You could create an iPhone display mode for example. Likewise, you could create a tablet display mode. Here’s some code:

var modeTablet = new DefaultDisplayMode("tablet")

{
   ContextCondition = (c => IsTablet(c.Request))
};var modeDesktop = new DefaultDisplayMode("")
{
   ContextCondition = (c => return true)
};
displayModes.Clear();
displayModes.Add(modeTablet);
displayModes.Add(modeDesktop);

When run from Application_Start, the code drops default modes and defines two new modes: tablet and desktop. The tablet mode is added first and will be checked first. The internal logic that finds the appropriate display mode, in fact, stops at first match. If the HTTP request is not matched to a tablet, it is then treated by default with a view optimized for a desktop device.

How would you reliably determine whether a given request comes from a tablet? It’s all about sniffing the user agent string; but you need a professional tool for that. The answer is getting a commercial license from a Device Description Repository vendor like ScientiaMobile for WURFL. Note that WURFL is only the most widely used (Facebook and Google use it) device database; it is free for open source projects and has a partly free cloud version. Other products exist too. But my point here is that you should not spend a second on crafting your own solution for sniffing user agent strings.

 



nopCommerce Hosting - Choose nopCommerce as Online Business Solution

clock March 18, 2013 08:00 by author andy_yo

Now days, there is a profusion of open source options for the person looking to establish an online business. Being a part of IT industry, We have seen my colleagues working on various open source solutions such as Magento, Open-cart and many more. But, none of them can make you feel the difference that one will experience while working on nopCommerce.

 

 

About ASPHostPortal.com
ASPHostPortal.com is Microsoft No #1 Recommended Windows and ASP.NET Spotlight Hosting Partner in United States. Microsoft presents this award to ASPHostPortal.com for ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2012, ASP.NET 4.5, ASP.NET MVC 4.0, Silverlight 5 and Visual Studio Lightswitch. Click here for more information

 

The main feature of this software is that it is very easy to manage and quite user-friendly. This was the reason why nopCommerce created a buzz in the market soon after it was launched. Unlike others, nopCommerce in not written in PHP or Pearl rather, it is completely written in ASP.Net 4.0 and nopCommerce developers have provided the backend of SQL 2005 which even today is considered as very powerful database management platform.

nopCommerce provides a catalog front end and easy to work with administrative backend, which completely allows the user to open their online business soon and manage it to perfection on their own.

Although, the software is developed in ASP.Net but anyone with basic computing and administrative skills can manage the software efficiently.

The nopCommerce is quite easy to customize and one can easily make categories or sub categories.

The various features that have made nopCommerce to emerge amongst the best is notification via sms, live chat, multiple currency and language support one page checkout procedure which ensures a low bounce rate, billing and shipping detail, mapping the products in the appropriate categories and sub categories and many more.

The nopCommerce is supported by fastest growing user community which has increased the technical as well as informative aspect of the solution. This also supports various popular gateways. It is amongst those few open source solutions that have been built keeping Search Engine Strategies in consideration.

This software can be downloaded from the internet for free and easily installed into the system. This open source solution is compatible with various systems in existence. As per the ongoing trend, free ecommerce solution is favored by most of the persons who have online business and is compatible with most systems. But the major point lies in NopCommerce is that being written in Asp.Net the security feature of the web site increases.

The main feature which is very important is that the exchange rate system is based on the real time prices. This has greatly helped the shoppers across the globe to shop freely irrespective of their current location.

Even though the software is built in a user friendly way, but during the initial phase it is recommended that you must hire a professional nopCommerce Developer until you get fully known to the nopCommerce functionality. There are various web design and development company who have expert nopCommerce developers.

 



Windows Hosting - Comparison Between DotNetNuke and WordPress

clock March 6, 2013 10:08 by author andy_yo

In the present market, a vast array of contenders in the CMS arena (Content Management Systems) are competing neck to neck; so selecting the best choice that precisely suits the requirements of your project, might be a tricky job. In the present article, we would like to provide a complete synopsis of 2 of the well-known products, namely WordPress and DotNetNuke (DNN) so as to assist you in choosing the best option.

 

About ASPHostPortal.com

ASPHostPortal.com is Microsoft No #1 Recommended Windows and ASP.NET Spotlight Hosting Partner in United States. Microsoft presents this award to ASPHostPortal.com for ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2012, ASP.NET 4.5, ASP.NET MVC 4.0, Silverlight 5 and Visual Studio Lightswitch. Click here for more information

 

Basic Info about the two CMS

DNN is basically an open source platform based on ASP.Net structure that is developed mainly to create dynamic websites and also provide many web applications. It has been an instant success since its initial launch, with the open community edition only being deployed in not less than 600,000 websites around the world.

On the other hand, WordPress is a MySQL and PHP-based framework, which is mainly used for blogging. It is one of the most widely acknowledged CMS platforms in the present world, but don’t feel that it’s only meant for blogging – today, millions of corporate websites and e-commerce stores are also powered by WordPress. WordPress Self-Hosting blogs are considered as main constraints. Choosing the best WordPress Hosting solution offers the desired results of your prediction. If you looking to make Web Development as your career, then it is the best time to choose Web Development as your career option.

Disparities in Underlying Technology

Both WordPress and DNN applications are developed based on open source, which clearly implies that both platforms can be liberally extended by your own highly-skilled development team. The chief dissimilarity between these two platforms is that WordPress is written using PHP, while in contrast, DNN is written using Visual Basic.Net.

As LAMP technology piles have started to widely use across the web, especially inside shared hosting atmospheres, it is most likely that WordPress would be much cheaper and easier to install.

Windows-based servers usually tend to be expensive, but DNN’s potential to interface with NTLM based windows authentication and Active directory makes it a supreme pick for use in many domain-based systems, including intranet websites.

Comparing Important Features

Wordpress was developed as an extremely simple blogging system, while DNN was designed to handle more complex web applications. This very fact is clearly reflected in the standard features that can be seen in both platforms.

DNN comes integrated with some special options including resizing and mass uploading, while in the case of WordPress, some additional add-ons need to be installed to perform those functions. DNN offers other features including macro/templating languages, prototyping, and zip archives, whereas you can’t find all these options built in WordPress, and it is gradually included all these functionalities over time. For instance, the 2.9 edition of WordPress has come with an Undo function, which was missing in its previous edition.

If you are looking forward to build a potentially huge scale website, then WordPress clearly lacks some of the basic important features that are very essential. Performance management features including load balancing and database application are considered as the fundamental parts of DotNetNuke, while WordPress fails to provide all these options.

Comparing Security Standards

Since its existence, WordPress has been constantly overwhelmed by many security-related issues, whereas the DNN has had only 7-security related queries, and all of which have been resolved now.

DNN provides excellent SSL logins and session management services than WordPress. So, from the security perspective, DNN would be an ideal choice as against WordPress.

The Bottom Line

On the whole, both DNN and WordPress are regarded as feasible choices for developing a new site, be it personal or business. With its light-weight design framework, WordPress is an ideal choice only for small-scale websites and blogs. On the other hand, DNN may be slightly expensive and difficult to install initially, but with its extensive set of security and standard features, it makes a better choice for large-scale website needs.

 

 



ASP.NET MVC 4 Hosting - Overriding Browser Capabilities in MCV 4

clock March 4, 2013 09:31 by author andy_yo

The new System.Web.WebPages 2.0.0.0 assembly that ships with the latest MVC4 contains a pretty cool feature that lets you override the current browser capabilities. Sure, most modern browsers let you set a custom user agent string out of the box or via extensions. However, there are certain scenarios, where you would want to switch the user agent on the server side. That’s where the BrowserHelpers class comes in handy.

Override Browser Context

A good example where you want to use override the browser capabilities is when developing mobile views. You may not want to simulate a particular device, you just want to tell ASP.NET that the client is a mobile device and to use the .mobile view.  You can call SetOverridenBrowser extension method and pass in BrowserOverride enum (Mobile/Desktop options).

public ActionResult Mobile()
{
    HttpContext.SetOverriddenBrowser(BrowserOverride.Mobile);
    return RedirectToAction("Index");
}

If you want, you can override the browser full UserAgent by calling SetOverridenBrowser extension method on HttpContextBase

public ActionResult Iphone()
{
  HttpContext.SetOverriddenBrowser("Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7");
    return RedirectToAction("Index");
}

And then, in order the clear the override, simple call the ClearOverridenBrowser extension method

public ActionResult Clear()
{
    HttpContext.ClearOverriddenBrowser();
    return RedirectToAction("Index");
}

What is happening under the hood

When you call the SetOverridenBrower method, ASP.NET sets a “.ASPXBrowserOverride” cookie. This is done using CookieBrowserOverrideStore from System.Web.Webpages, which implements BrowserOverrideStore – if you’re interested, check it out in dotpeek.

The value of the cookie is the user agent that you have set or in the case of the BrowserOverride.Mobile enum: Mozilla/4.0 (compatible; MSIE 6.0; Windows CE; IEMobile 8.12; MSIEMobile 6.0). The expiry date is set for 7 days so the override will be in place even if you re-open your browser. Calling ClearOverridenBrowser simply clears the cookie.

Create Mobile Switched Filter

The jQuery.Mobile.MVC package comes with the ViewSwitcher razor partial and the ViewSwitcherController. This does more or less exactly what I described above. However, if you are lazy like me, you may want to switch between mobile/desktop views using QueryString rather than controller/actions.  This is useful when you want to just quickly check your mobile views.

public class BrowserCapabilitiesSwitcherFilter : ActionFilterAttribute
{
    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        var switchParameter = filterContext.RequestContext.HttpContext.Request.QueryString["switch"];
        if(string.IsNullOrEmpty(switchParameter))
            return;
        var browserOverride = BrowserOverride.Desktop;
        if(Enum.TryParse(switchParameter, true, out browserOverride))
        {
            //switch between BrowserOverride.Desktop / BrowserOverride.Mobile
            filterContext.RequestContext.HttpContext.SetOverriddenBrowser(browserOverride);
        }
        else
        {
            //set the user-agent string
            filterContext.RequestContext.HttpContext.SetOverriddenBrowser(switchParameter);
        }           
    }
}

Simply use it by typing http://yoursite.com/page?switch=Mobile to preview in mobile and then http://yoursite.com/page?switch=Desktop to switch back. For the more adventurous, you can pass in the user agent directly http://yoursite.com/page?switch=UserAgentString

 

 



ASP.NET MVC 4 Hosting - Mobile Views Setting in MVC 4

clock February 27, 2013 07:54 by author andy_yo

MVC 4 has a new way to deal with mobile views.  You can now set up individual display modes for mobile and desktop views.  First you need to register the new display mode in the app_start method of the global.asax file.

DisplayModeProvider.Instance.Modes.Insert(0

       , new DefaultDisplayMode("mobile")

       {    

          ContextCondition = (ctx => ctx.Request.Browser.IsMobileDevice)

       });

Here we added a display mode called “mobile” that we set the condition to use this new mode to mobile devices.  Now we would create a controller and view as usual.  Say we create a Home controller with an Index action.  Next we create a new view using the razor engine called Index.cshtml.  To use the newly created display mode we would just create a second view and call it index.mobile.cshtml.  By using this naming convention we are telling MVC to use the index.cshml view for all requests to the Home controller and Index action, but if the condition of the display mode is met, use the index.mobile.cshtml view.  One of the real nice things about this approach is that if a request meets the condition for a mobile view, but one doesn’t exist, it will default back to the desktop view.

You can also use this same convention with master pages.  For the _layout.cshtml, you would add a _layout.mobile.cshtml.  Be careful though, as a side effect of the view defaulting back to the desktop view if the mobile one doesn’t exist, you can get a mismatch of master page and view.  If this is not desirable, then can add the following line into your _ViewStart.cshtml file of your site:

DisplayModeProvider.Instance.RequireConsistentDisplayMode  = true;

This is a great way to set up you site with a mobile view and a desktop view and use the same controller for both.

 



ASP.NET MVC 4 Hosting - Razor 2.0 Features in ASP.NET MVC 4

clock February 19, 2013 12:26 by author andy_yo

First version of razor is shipped with ASP.NET MVC 3. ASP.NET MVC 4 come with Razor V2.0. Razor V2.0 includes some new features.

About ASPHostPortal.com
ASPHostPortal.com is Microsoft No #1 Recommended Windows and ASP.NET Spotlight Hosting Partner in United States. Microsoft presents this award to ASPHostPortal.com for ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2012, ASP.NET 4.5, ASP.NET MVC 4.0, Silverlight 5 and Visual Studio Lightswitch. Click here for more information

 

URL Resolution Enhancements:

We use the relative URL for any resources (images, scripts, css) in code , for example :

<script src=”~/Scripts/jquery-1.8.2.js”></script>

But in runtime we should resolve the full path of the resource (absolute URL), to do this in ASP.NET MVC 3 we use Content() method of UrlHelper class.

<script src=’@Url.Content(“~/Scripts/jquery-1.8.2.js”)’></script>

In Razor V2.0 no need to use @Url.Content() method, razor v2.0 now resolves (absolute path/URL) ~/ (tilde-slash) within all standard HTML attributes, razor v2.0 now allows you to just write  :

<script src=”~/Scripts/jquery-1.8.2.js”></script>

Conditional Attribute Enhancements:

Hers is a classic example for conditional attributes, I have a <div> tag with class attribute. The class name is a dynamic value, It will be resolved at runtime based on some condition in razor code. If the condition is satisfied  class attribute will have some value, else it will be null. When there is a value no issues, but when value is null  we should not apply it for class attribute, to be strict when there is no value for class attribute we should not render it. This scenario involves with writing some ugly code with if condition & <text> tag, in Razor1.0 (ASP.NET MVC 3) code snippet as follows.

 

In Razor 2.0 (ASP.NET MVC 4) now we can write:

 

 

Above code returns the same results as earlier, for example if the @ViewBag.UseRoundCorners value is true, then myClass value is roundCorners, then  razor will render :

<div class=”roundCorners ”></div>

If @ViewBag.UseRoundCorners value is false, then myClass value is null, then razor will render <div> tag with out class attribute:

<div></div>

Razor V2.0 can handle multiple values in conditional attributes:

For example class attribute has multiple values <div class=”@myClass heading”></div>, now razor will render <div class=”roundCorners  heading”></div> if @myClass is not null, if @myClass is null, then razor will simply render <div class=”heading”></div>.

Razor V2.0  can handle Boolean values in conditional attributes:

Not only null values & multiple values, razor can handle boolean values also in conditional attributes.

<input type=”checkbox”  checked=”@ViewBag.Checked” />

If @ViewBag.Checked value is true then razor will render:

<input type=”checkbox”  checked=”checked” />

If @ViewBag.Checked value is false then razor will render:

<input type=”checkbox”  />



DotNetNuke Hosting - DotNetNuke versus Joomla

clock February 5, 2013 05:45 by author andy_yo

DotNetNuke and Joomla are two very popular CMS (Content Management Systems) based on different technologies. DotNetNuke is a content management system written in Visual Basic and based on the Asp.Net framework, whereas Joomla is based on the popular PHP framework. Each has its own advantages and disadvantages which we will discuss further in detail.

About ASPHostPortal.com

ASPHostPortal.com is Microsoft No #1 Recommended Windows and ASP.NET Spotlight Hosting Partner in United States. Microsoft presents this award to ASPHostPortal.com for ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2012, ASP.NET 4.5, ASP.NET MVC 4.0, Silverlight 5 and Visual Studio Lightswitch. Click here for more information

Core Functionality: DNN offers extensive core functionalities in front of which Joomla seems a little weak. DNN offers features like database replication, event management, photo gallery and built-in forum system. Joomla also offers various functionalities that are not available in any other PHP based CMS, such as load balancing and a trash bin to ensure that articles are not accidentlly deleted. However, Joomla still falls short of DNN in context of their core functionalities.

Customization and Extensions: Joomla compensates the lack of core functionalities by allowing extensive third party plugins and customization facilities. Joomla provides a core framework around which developers can develop any site with desired functionalities. There is a plugin available for everything in Joomla therefore extra functionality can be added and customized according to client's requirements. Moreover, vast number of templates are available on the internet from which developers can chose the suitable themes and customize them according to their needs.

However, the template designs in Joomla are often based upon similar layouts which usually end up in the development of too many similar looking websites with slight changes in the design and color. DNN however offers a high level of flexibility thus provides an opportunity to create unique websites.

Basic Technology: Both Joomla and DotNetNuke are built upon different technologies which makes it essential to take their technical differences into account. Joomla uses technologies like PHP and MySQL backend which are extensively used for web development and web application development. On the other hand, DotNetNuke uses technically superior Asp.net framework from Microsoft which is too expensive for regular web-hosting environment. However, small and medium businesses usually have servers running on Microsoft's IIS which eliminates the open source advantage of Joomla.

DotNetNuke is more useful and feasible for corporate and enterprise intranets which require to integrate with the existing systems that are usually built using the same technology. They require sophistication, flexibility and robustness which are offered by DNN and can also be easily afforded by enterprises. Whereas, Joomla is designed to provide quick, expandable and cost effective web presence.

Support: The DotNetNuke offers extensive support depending upon the edition you have. The basic version provides developers forum through which users can get assistance from various other developers active on the forum. The paid "professional" version offers unlimited online support whereas the "Elite" edition provides live telephonic support with response under 2 hours. Joomla does not provide paid support system but there are various third party organizations offering training and support for Joomla.

The paid versions of DotNetNuke, i.e. "professional" and "elite" version are extensively tested and verified officially which makes them a good choice for business applications that require stability and perfectness.

Ease of Usage: DotNetNuke allows for quick and easy content editing functionality whereas in Joomla users have to first sign into a different section on the site before they can make changes to content. You can easily change the position of modules in DNN by drag and drop functionality which makes it so easier. Apart from this both the frameworks offer similar ease of use via features such as built in macro languages, ability to mass upload and search engine friendly URLs.

While comparing them we just cannot declare one better than the other as each has some advantages and disadvantages of its own. What we can say with certainty is that DotNetNuke is better for business applications and creation of business scale websites whereas Joomla is ideal for making quick, functional and cost effective web sites.

 

 



Cloud Hosting - Advantages of Cloud over traditional Shared Server

clock February 4, 2013 09:33 by author andy_yo

Everyone is interested in cloud hosting at this moment in time. Traditionally, websites have been hosted on standard dedicated servers. Dedicated servers host lots of websites. On each dedicated server, a shared hosting account is kept. A dedicated server for email or Mysql is sometimes employed. When it comes down to it though, all your eggs are in one basket. The obvious downside of this is that if the dedicated server develops a fault, your website will be down. Cloud server is different. Cloud panels have numbers on its side.

 

About ASPHostPortal.com

ASPHostPortal.com is Microsoft No #1 Recommended Windows and ASP.NET Spotlight Hosting Partner in United States. Microsoft presents this award to ASPHostPortal.com for ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2012, ASP.NET 4.5, ASP.NET MVC 4.0, Silverlight 5 and Visual Studio Lightswitch. Click here for more information

Cloud server is extremely scalable, as in you can choose to pay for what resources you use. It’s very like mobile phones that offer a pay as you go tariff. If you use a small amount of resources, you only pay for those resources. If you are suddenly hit with loads of traffic, the cloud will let you expand instantly. Cloud hosts automatically assign what power you need. Your website should never go offline because of an unexpected spike in traffic. You would simply be billed for the extra used. In this respect, cloud hosting is more cost effective. Remember you are still in a virtual hosting environment of your own- no sharing. No need for an expensive dedicated server anymore.

Cloud hosting is more reliable. Whether cloud hosts are more reliable is the subject of fierce debate. There are however, many arguments for. We looked at the scenario of standard shared hosting where if one single dedicated server fails, your website goes offline. Cloud hosting is made up of many many nodes or dedicated servers. Thus you can weather one or even two nodes going offline at the same time. Cloud hosting surely has to be considered more reliable.

Deploying cloud hosting is very quick and easy. Deploying the hardware is the first part of dedicated server hosting. Then you have to setup software and services. Cloud hosting knocks this issue on the head. You slot in servers as and when you need them. One thing to consider about cloud hosting, is it is a relatively new technology. There are a few down sides with cloud hosting, where a traditional dedicated server or shared hosting environment can offer bigger benefits. However, the reliability cost and scalability of cloud software wins hands down. Those hosts that don’t already have a cloud product, are developing one right now. This speaks volumes. Cloud hosting certainly has more benefits over traditional hosting. Watch clouds continue to improve as cloud software does.

 



WebDeploy Hosting - Advantages of using WebDeploy over FTP

clock February 1, 2013 15:01 by author andy_yo

What is Web Deploy?

Web Deploy is an extensible client-server tool for syncing content and configuration to IIS. Web Deploy is used primarily in two scenarios:

  1. Developers use it to sync (aka ‘publish’) a compiled web applications (ASP .Net, PHP etc) from developer tools (Visual Studio, WebMatrix, etc) to IIS
  2. IT professionals use it to migrate websites & applications from an operating system running an older version of IIS such as IIS6 to an operating system running a newer version of IIS such as IIS 7.5.

Comparison between WebDeploy and FTP

Web Deploy is often compared to technologies like FTP, XCOPY or RoboCopy. While these technologies are useful, Web Deploy offers several benefits.

About ASPHostPortal.com

ASPHostPortal.com is Microsoft No #1 Recommended Windows and ASP.NET Spotlight Hosting Partner in United States. Microsoft presents this award to ASPHostPortal.com for ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2012, ASP.NET 4.5, ASP.NET MVC 4.0, Silverlight 5 and Visual Studio Lightswitch. Click here for more information

Here is a comparison of Web Deploy to FTP:

  1. Web Deploy is faster than FTP. Web Deploy does not issue a different command for each operation. Instead, it does a comparison at the start of the sync and only transfers changes.
  2. Web Deploy is secure. Web Deploy supports transfer over HTTPS. Note that variants of FTP such as SFTP and FTPS are also secure.
  3. Web Deploy can set security descriptors (ACLs) on destination files and directories. For example, you can use Web Deploy to give a Windows user specific access to your application’s ‘Downloads’ folder during deployment.
  4. Web Deploy can publish databases. Web Deploy has out-of-box support for scripting out SQL Server, MySQL Server, Sqlite and SQL Server Compact databases and applying the resulting script during the sync. This can be very handy if your app needs a database to function.
  5. Web Deploy can apply transforms during deployment. You can use Web Deploy to change a connection string or application setting during a sync. Web Deploy supports a large range of transforms, including transforming IIS settings.
  6. Web Deploy integrates with Visual Studio 2010 and WebMatrix.
  7. Web Deploy is extensible. Web Deploy has a rich, publicly-accessible extensibility model which lets you author new scenarios.


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