Archive for the ‘MVC’ Category

VS.NET 2013 and ASP.NET MVC 5!

July 14, 2013

Hello friends, ASP.NET MVC 5 has been bundled with VS.NET 2013 preview release. Here are few links for your reference.

VS.NET 2013:

The below url has the fantastic list of information about ASP.NET and Web Tools for Visual Studio 2013 Preview as well as the updated ASP.NET and Web Tools. Enjoy reading!

http://www.asp.net/vnext/overview/latest/release-notes#TOC10

ASP.NET MVC 5:

Tutorial available for Getting Started with ASP.NET MVC 5.
http://www.asp.net/mvc/tutorials/mvc-5/introduction/getting-started

Note:
The ASP.NET MVC Framework is an open source web application framework that implements the model–view–controller (MVC) pattern.

http://aspnet.codeplex.com/wikipage?title=MVC

As of now, the download is available for MVC 4 only.

Just a pointer to the title related information. 🙂

VS.NET 2012’s new features in “MVC 4, Razor v2”

August 24, 2012

Here are two cool enhancement in Razor v2! Enjoy reading!!

1. No need to use “@href” or “@url.content” anymore for resolving the Url. We can simply use “~” as we use it in ASP.NET development

Example:
< script src=”@Url.Content(“~/Scripts/jGrowl.js”)”>

can be just simply as below
< script src=”~/Scripts/jGrowl.js”>

Note: <space> has been added after “<” in < script> for the perfect view

2. Conditional attributes:

Please refer: http://vibrantcode.com/blog/2012/4/10/whats-new-in-razor-v2.html/

Pagination / Sorting not works in Custombinding enabled Telerik mvc grid ( v 2011.2.712 ) !

September 19, 2011

I experienced this issue in my development and lost some time figuring out!

Problem description:

Let’s say I have start date & end date and go button for the search and the search result will get displayed in the MVC grid. If I fire rebinding from JavaScript with both the date values, the grid would populate fine. But if I go for sorting/pagination, the “gridcommand” object holds only pagesize and pageno and misses the filter values for start & end date and grid goes with the default data population. But it worked fine with the previous version 2010.3.1318.

The solution is here:

“The additional parameter values passed through Grid’s client-side rebind method are not presisted on subsequent rebinds”

In previous version, as a side effect of another issue, when additional value is passed through the rebind client-side method, it was persisted during the subsequent rebinds. In order to achieve same behavior with current version, the DataBinding event should be use to re-assign the value.

Here you go for the examples:

http://www.telerik.com/help/aspnet-mvc/changes-and-backward-compatibility.html

Hope, it helped!

ASP.NET MVC 4 Preview Released

September 18, 2011

Hope, the following notes and links would help great!

It installs side-by-side with ASP.NET MVC 3, so get started using it today!

Top Features

  • Refreshed and modernized default project templates
  • New mobile project template
  • Many new features to support mobile apps
  • Recipes to customize code generation
  • Enhanced support for asynchronous methods
  • Read the full feature list in the release notes http://www.asp.net/learn/whitepapers/mvc4-release-notes

Software Requirements

The ASP.NET MVC 4 runtime components require the .NET Framework 4. The ASP.NET MVC 4 components for Visual Studio require either Visual Studio 2010 with Service Pack 1 or Visual Web Developer Express 2010 with Service Pack 1.

For reference:

http://theshravan.net/blog/asp-net-mvc-4-roadmap/

http://www.dotnetexpertguide.com/2011/09/aspnet-mvc-4-article-series.html

http://www.dotnetexpertguide.com/2011/09/first-look-at-aspnet-mvc-4-templates.html

http://www.kevinlabranche.com/blog/ASPNETMVC4DeveloperPreviewGoodness.aspx

Glimpse, debugging server from client side!

June 28, 2011

What is Glimpse (= a glance)?

http://getglimpse.com/

At its core Glimpse allows you to debug your web site or web service right in the browser. Glimpse allows you to “Glimpse” into what’s going on in your web server. In other words what Firebug is to debugging your client side code, Glimpse is to debugging your server within the client.

“What Firebug is for the client, Glimpse does for the server… in other words, a client side Glimpse into whats going on in your server.”

Plugins available for Winforms & MVC:

WebForms MVC
  • Config – Summary of important stuff in your web.config
  • Environment – Details of the server environment
  • Request – What the server received in the request
  • Server – Web server variables available for the request
  • Session – Is using session, what is being stored
  • Trace – Trace output for the request
  • Bindings – How MVC is binding the data
  • Execution – What the execution pipeline looks like
  • MetaData – MetaData associated with your View Model
  • Routes – How routes are being evaluated
  • Views – How MVC is finding the view that is being rendered

Steps to install & use:

Sample firebug like window:

Hope, you would enjoy reading!

MVC 3 View engine Razor and comparision!

February 7, 2011

Benefits over Razor are

  1. Can be hosted outside ASP.NET
  2. Can unit test views (no need of controller or web-server)
  3. Better intellesense support on VS.NET
  4. Everything is encoded by default
  5. Executing it from a console app is possible
  6. Much cleaner
  7. There’s no need to specify the language, because it’s included in the extension
  8. No need to explicitly specify a master page
  9. No external dependencies as it has been shipped with MVC 3 (System.Web.Mvc.dll)
  10. and lot more

Below are the urls you could enjoy reading over the major 4 view engines, it’s awesome. Just including here as it would help some one over there.

  1. http://channel9.msdn.com/coding4fun/articles/Developer-Review-Four-ASPNET-MVC-View-Engines
  2. http://ironshay.com/post/The-Big-View-Engine-Comparison-e28093-Razor-vs-Spark-vs-NHaml-vs-Web-Forms-View-Engine.aspx

Asp.Net MVC project “The project type is not supported by this installation”

February 7, 2011

One of my team members experienced this issue and was trying all the tricks got from googling, but those are all did not helped him great. After some time, we got a clue from one of the tips and verified System.Web.Mvc version in the project file.

<Reference Include=”System.Web.Mvc, Version=3.0.0.0,…>

We use VS.NET 2010. He had only System.Web.MVC 2.0 installed in his machine but the above entry was showing version 3.0. Then right away we installed MVC 3.0 and tried opening the solution. Wow…it’s worked like a charm.

Hence, if you see System.Web.Mvc Version=2.0.0.0, make sure you have MVC 2.0 installed. Likewise if see Version=3.0.0.0, make sure MVC 3.0 installed. That’s it  🙂

 

ASP.NET MVC 3 & New view engine “Razor”!

February 6, 2011

Most of you must have heard about MVC 3 has been released few months ago with the big bang! It has come up with too many features and improvement. Thought of giving some quick info and links related to that.

Find below the link from Scottgu depicting about the same. Excellent one!

http://weblogs.asp.net/scottgu/archive/2010/11/09/announcing-the-asp-net-mvc-3-release-candidate.aspx


Top features:

  • New view engine called “Razor” with much simplified
  • Support for Multiple View Engines
  • Powerful hooks with Dependency Injection and Global Action Filters
  • Rich JavaScript support with unobtrusive JavaScript, jQuery Validation, and JSON binding
  • Streamlined validation with improved Model validation

Here is the pointer over Razor:

http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx


Web form Vs Razor syntaxt comparision and example from haacked.com, i loved this very much 🙂

http://haacked.com/archive/2011/01/06/razor-syntax-quick-reference.aspx

One more interesting part, yes..there is a tool you can convert WebForms(asp.net) Views to Razor (C# Only). Actually it was developed by the Telerik ASP.NET MVC team for internal use, but now it is available free over GitHub.com.

Here you go….https://github.com/telerik/razor-converter. There are some limitations with this tool, check it out there.

Enjoy playing with MVC 3!

ASP.NET MVC – Exception Handling – Un Handled exception

December 4, 2010

In one of our new development, client team decided to start with ASP.NET MVC. As I knew only the plain MVC, I started exploring ASP.NET MVC little better. Over there, I tend to check about exception handling.  And found great about the in-built error handling using attribute [HandleError] at Class (Controller) level or Methods (Action) level.

1). In-Built way:

  1. MVC’s In-built attribute [HandleError] at Class(Controller) level or Methodd (Action) level
  2. We need <customErrors mode=”On” /> in web.config, so that by default, webserver will take us to view “/Shared/Eorror.aspx”
  3. Easily configurable
  4. No need of try…catch
  5. No logging is here

One quick reference:

http://weblogs.asp.net/scottgu/archive/2008/07/14/asp-net-mvc-preview-4-release-part-1.aspx

2). With Logging:

  1. We can create a custom attribute like [LogError] by inheriting and implementing ActionFilterAttribute, IActionFilter respectively
  2. We can decorate with both the attributes [HandleError] and [LogError]
  3. Can be logged in any of the stores like TXT/Xml/SQLServer or etc. We have to have our own classes to do this

One quick reference: http://www.singingeels.com/Articles/Logging_with_ASPNET_MVC_Action_Filters.aspx

In the continuation, I came across one open source project called ELMAH. It’s really awesome!

3). Open Source – ELMAH (Error Logging Modules and Handlers) way:

  1. Provides the capability logging in several available persistence stores like SQLServer, Xml , Memory and etc
  2. Provides a page handler (Ex: elmah.axd)  to view the all errors in HTML form
  3. No need to add any attributes to Controller or Method.  Having a ControllerFactory, we can inject them through Application_Start() from Global.asax.cs
  4. No [HandleError] attribute, ELMAH takes care

The things need to do are:

  • Need to add ELMAH.DLL
  • Add some configuration stuffs in Web.config
  • One dummy ActionResult to redirect to Error page, which can be configured in

Urls for quick reference:

  1. http://www.hanselman.com/blog/ELMAHErrorLoggingModulesAndHandlersForASPNETAndMVCToo.aspx
  2. http://dotnetdarren.wordpress.com/2010/07/27/logging-on-mvc-part-1/ – Download the sample here
  3. http://dotnetslackers.com/articles/aspnet/ErrorLoggingModulesAndHandlers.aspx
  4. http://www.codecapers.com/post/Error-Handling-in-MVC-with-ELMAH.aspx#tb

Here are the benefits I see are:

  1. No need of try…catch block, throwing and re-throwing
  2. Provides different stores
  3. Page to view all the errors (Report) and export into different form
  4. Notification by email can be configured and too many