Tuesday, February 15, 2011

Parser Error Message: Could not load type 'System.Web.Mvc.ViewPage

                     Hi all,

                         Recently I have faced one of the exception in my Project .I have got this exception when I  integrated  my code with my colleague’s solution .I have taken different approaches to find the problem but no use .Finally I fixed the issue. The purpose of this post is  for anyone  else who might be experiencing this particular pain…

                       The problem is  “view engine has problems compiling strongly typed base class in Inherit attribute”  Check  your  project View folders web.config file having following references .If not add these and run the application .It works..

Remove below page section  if already in web.config

      <add namespace="System.Web.Mvc" />
      <add namespace="System.Web.Mvc.Ajax" />
      <add namespace="System.Web.Mvc.Html" />
      <add namespace="System.Web.Routing" />

And add this  pages section in web.config .


     pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
     pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
     userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
            <add assembly="System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />

Why to add @ symbol for class in HTML extenstion control in ASP.NET MVC

                    There is a small difficulty you feel when you are working
HTML helper methods.You can not add  some of properties directly to the HTML helper methods.
ex: class

                     The problem is here  C# compiler doesn’t expect you to use C# reserved words as property names. So, if you try to render a class attribute by passing new { class = "myCssClass" }, you’ll get a compiler error (class is a reserved word in C#). To avoid this problem, prefix any C# reserved words with an @ symbol (e.g., write new { @class =
"myCssClass" }). That tells the compiler not to treat it as a keyword. The @ symbol disappears during compilation(as it’s just a hint to the compiler), so the attribute will be rendered simply as class.

   1: = Html.TextBox("LastName", Model.LastName, new { @class = "width-600" })

Tuesday, February 1, 2011

ASP.NET MVC with localization


                 The ASP.NET MVC Framework is a web application framework that implements the model-view-controller pattern.It is a proven pattern for web application

                Implementing localization in ASP.NET is different from ASP.NET MVC.In my previous post I described the better practices to go for  localization in ASP.NET, Now I am going to  explain  how we can achieve localization in ASP.NET MVC 2.0.

Step#1 :

  • Add Global Resource folder to your  solution
  • Right click on the folder and add new item
  • Add resource file in dialog box and rename it “Common Resource”
  • In the below picture you can able to see the Global list of Resource files which I have added to my solution


.      Add the Local Resource folder and add resource  files as I specified below .


                Add  resource keys and there values in resource file .Here I have  taken two resource files.One is en(English)  language and second one is te (telugu).For telugu language I have taken Google Telugu type help   and I have added  those values into telugu  resource file .




                     Add this code into global.asax .I have added this AcquireRequestState event .It will be better to add in Session Start event to improve the performance .

protected void Application_AcquireRequestState(object sender, EventArgs e)
           CultureInfo ci = new CultureInfo(Request.UserLanguages[0]);
           System.Threading.Thread.CurrentThread.CurrentUICulture = ci;
           System.Threading.Thread.CurrentThread.CurrentCulture =



                 Right click on the resource file and go to the properties and change the properties values as I showed below.



Change the acess modifires internal to  public of each resource file


Run the application

       Before run the project  Change the UI culture in browser settings (I have changed to te[telugu]) .Now you can see the page with telugu language.