Monday, January 16, 2017

MVC 4 Rajor - [A]System.Web.WebPages.Razor.Configuration.HostSection cannot be cast to [B]System.Web.WebPages.Razor.Configuration.HostSection

Hello guys,

I was doing a MVC project for one of my client and received following error when i updated my MVC version from Library Package Manager > Manage NuGet Packages for Solutions...

[A]System.Web.WebPages.Razor.Configuration.HostSection cannot be cast to [B]System.Web.WebPages.Razor.Configuration.HostSection. Type A originates from 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Razor\v4.0_2.0.0.0__31bf3856ad364e35\System.Web.WebPages.Razor.dll'. Type B originates from 'System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vs\1779caca\ec838677\assembly\dl3\3dd21433\efc909b6_6889d201\System.Web.WebPages.Razor.dll'.

 This weird error was making me crazy. After lot of search on internet i found some article specifying the error caused by version. You can clearly make out from above error its true.

I found out that of Web.config resides inside the View folder of my project was referring to version 2.0.0.0. I have just changed the all versions from 2.0.0.0 to 3.0.0.0 in following section






Hola!!!!!!!!!!!!!!!!

Error gone...





Wednesday, January 11, 2017

Azure Series - Hosting Angular 2 site in Azure environment

I just started in angular 2 TS script development and I wanted to showcase my demo to my senior management. The demo site was on my laptop. It was not possible for me to take my laptop every time to a different person to show my demo site.
I was searching on the net for how to host my angular demo site on the web/Internet so that I can easily showcase my skills. I hosted my first angular app on the Azure environment. Azure App Service has first-class ASP.Net , Node.js, Java, PHP, and Python support. It's very easy just follow the following steps:

Prerequisites:

  • Make sure you have synchronized your code in the GitHub repository.

Steps:

  1. Get your Azure subscription (If you don't want to buy it's free for 30 days).
    https://azure.microsoft.com/en-us/free/ 

  2. Create a Web App in the APP Service module once you have a subscription.



  1. Once the application is created, select "Deployment Options".

  1. Select the source to deploy files.


You can choose different sources as per your choice:

  1. In my case, I selected GitHub.
  2. Provide credentials for GitHub when prompted.
  3. Select the Project from GitHub
  4. Select Branch.

You are done. Let the Synchronization happen and you are ready to browse your Angular Application.

Note: I guess and I am not sure since when I hosted my Angular App it was running without any issues. I suspect the node_modules directory is already added by Microsoft when you create the web app since they support Node.js.