Showing posts with label ASP.NET MVC. Show all posts
Showing posts with label ASP.NET MVC. Show all posts

Monday, June 24, 2013

Npgsql's status for supporting EntityFramework

In this article (Npgsql Code First Entity Framework 4.3.1 Sample), I have learned that the current version of Npgsql - PostgreSQL's .NET Driver - only supports EntityFramework4, NOT supports EntityFramework5. And it the next article (Initial EF-6 support added to Npgsql), the next version of npgsql will support EntityFramework6 (may support EntityFramework5).

Monday, November 19, 2012

I've finished reading "Programming Microsoft ASP.NET MVC, Second Edition"

I've finished reading the Japanese edition of "Programming Microsoft® ASP.NET MVC, Second Edition".

  • This book deals with ASP.NET MVC just literally. In other words, This book does not deal with EntityFramework.
  • But, this book is useful for understanding internal architecture of ASP.NET MVC 3.
  • Japanese edition's appendix (about ASP.NET MVC 4) is not enough, so I wait for its next edition!

Tuesday, September 18, 2012

VWDExpress 2012 goes green for F#

A week ago, Micsosoft announced about F# Tools for Visual Studio 2012 Express for Web in this blog. That is the biggest reason for using VWDExpress 2012 instead of VWDExpress 2010.
And This can install F# MVC4 tools.

Tuesday, August 21, 2012

cache_page directive for ASP.NET MVC

In Ruby on Rails, we should cache the response of the page with cache_page directive on controller.
class SampleController < ApplicationController
  caches_page :home
  caches_action :home_with_filter

  def home
    ...
  end

  def home_with_filter
    ...
  end
end

I learned from the book Programming Microsoft® ASP.NET MVC, Second Edition that we should use System.Web.Mvc.OutputCacheAttribute class on each actions like below:
public class SampleController : Controller

    [OutputCache(Duration=10)]
    public ActionResult Home()
    {
        ...
    }
end

The advantage of rails way is there are two directives: cache_page and cache_action. cache_page does not execute any actions and filters, but, cache_action only executes filters while ASP.NET MVC has only OutputCache attritbute that does not execute any actions and filters too.

On the other hand, the advantage of ASP.NET MVC way is easy to define expiration seconds of caching while rails' one is more difficult.

Thursday, August 16, 2012

ASP.NET MVC 4 is also ready for VWDExpress 2010 too.

In these days, Many Microsoft products comes to RTM. These products are for Windows 8 , .NET 4.5, Visual Studio 2012 and so forth. But, ASP.NET MVC 4 is also ready for Visual Studio 2010 and VWDExpress 2010 (in other words, ASP.NET MVC 4 runs on .NET 4.0 too).


After installation, dialog contains some projects related with ASP.NET MVC 4 like below:

Saturday, August 4, 2012

errors.add for ASP.NET MVC

In Ruby on Rails, we should add error information of model with errors.add method from ActiveModel::Errors class.
  errors.add(:customer, 'Invalid country.')

I learned from the book Programming Microsoft® ASP.NET MVC, Second Edition that we should add error information of model with ViewData.ModelState.AddModelError method from System.Web.Mvc.ModelStateDictionary class.
    ViewData.ModelState.AddModelError("Customer", "Invalid country.");

Thursday, July 19, 2012

Protect mass assignment for ASP.NET MVC

In Ruby on Rails, we should protect mass assignment with defining attr_protected (black list) or attr_accessible (white list) on Model like this (via Ruby on Rails Guides).

(black list)
class SomeModel
  attr_protected :admin
  ...
end
(white list)
class SomeModel
  attr_accessible :name
  ...
end

I learned from the book Programming Microsoft® ASP.NET MVC, Second Edition that we should protect mass assignment with defining attribute on argument of Action method, not on Model directly.

(black list)
[HttpPost]
public ActionResult Create([Bind(Exclude="admin")]SomeModel model)
{
    ...
}
(white list)
[HttpPost]
public ActionResult Create([Bind(Include="name")]SomeModel model)
{
    ...
}

The best advantage of this approach is to be able to define black lists or white lists in each actions.

Monday, July 16, 2012

routes.MapRoute

In Ruby on Rails, we define request route on config/route.rb as DSL like this:
match ':controller(/:action(/:id))(.:format)'

I learned from the book Programming Microsoft® ASP.NET MVC, Second Edition that we define request route (1) on Global.asax as RegisterRoutes method or (2) on XXXXAreaRegistration.cs as RegisterArea method, in ASP.NEt MVC. This is the sample:
public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    routes.MapRoute(
        "Default", // Route name
        "{controller}/{action}/{id}" // URL with parameters
    );
}

If we want to set default value for route, add anonymous object as 3rd parameter:
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 = UrlParameter.Optional } // Default value for parameters
    );
}
In this sample, UrlParameter.Optional means the rest of parameters.

And then, if we want to set constraint for route, add anonymous object as 4th parameter:
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 = UrlParameter.Optional }, // Default value for parameters
        new { id = @"\d{8}" } // Constraint for parameters
    );
}

Friday, June 15, 2012

Windows 8 release preview and ASP.NET MVC4

2 weeks ago, Windows 8 release preview and Visual Studio 2012 RC had been released. As you see, "Visual Studio 11" has been renamed to "Visual Studio 2012", and Express SKUs are ready. So I try "Visual Studio Express 2012 for Web" to develop ASP.NET MVC4.


Monday, May 7, 2012

Start reading "Programming Microsoft ASP.NET MVC, Second Edition"

I have started reading the Japanese edition of "Programming Microsoft® ASP.NET MVC, Second Edition".


The cover of English edition is below:

But, Japanese edition contains the great appendix - about ASP.NET MVC 4.

Saturday, April 7, 2012

ASP.NET MVC becomes Bazaar model

About 2 weeks ago, ASP.NET MVC becomes Bazaar model.

ASP.NET MVC, Web API, Razor and Open Source
ASP.NET MVC Now Accepting Pull Requests

In other words,

  • ASP.NET MVC had started to accept pull request from outside
  • ASP.NET MVC changed its license from Ms-PL to Apache Licence

Monday, March 12, 2012

Windows 8 customer preview and ASP.NET MVC4

2 weeks ago, Windows 8 customer preview and Visual Studio 11 beta had been released. The most notable feature for me is that Visual Web Development supports ASP.NET MVC4 by default. Now I'm learning.

Tuesday, February 21, 2012

The future of MVC4

One week ago, Microsoft announced that ASP.NET MVC4 beta had been released. And Scott Guthrie said some important things in his blog like below:
  • ASP.NET MVC4 installer contains EntityFramework 4.3
  • ASP.NET MVC4 installer contains Razor template engine v2
  • ASP.NET MVC4 only supports .NET Framework 4 and VisualStudio 2010. In other words, it doesn't support .NET Framework 4.5 and VisualStudio 11 at this beta release. These all will be supported at RTW in this September.

Wednesday, October 12, 2011

MySQL Connector/Net 6.4.4 has been released

In two weeks ago, MySQL Connector/Net 6.4.4 has been released(Check change log).

You may think this release is small bug-fix one. But, for ASP.NET MVC3 / EntityFramework4 developer, this contains big change. Since this release, "Code first" function runs correctly with PluralizingTableNameConvention. So you don't have to remove this convention like this post anymore!

Wednesday, July 13, 2011

ViewBag is not living in redirected action

ViewBag - a place holder between action and view - is living in one response. In other words, ViewBag is not living in redirected action despite the fact Rails' flash go living. Then, what should we use? It is TempData

Wednesday, July 6, 2011

Updated MySQL Connector/Net

Current MySQL Connector/Net is 6.3.7, and this version can do code first in limited condition. This post expresses the instruction of code first with MariaDB.

Tuesday, June 28, 2011

Selected as an LTer

I've selected as an Lightning Talker in RubyKaigi2011.

Lightning talks 1 - July 17, 2011 (Main Hall)

My LT title is Yet Another "ASP.NET MVC 3 vs. Ruby on Rails 3".

I will do my best!!

Goodies

RubyKaigi staffs release some goodies in here.

Thursday, May 26, 2011

Yet another simple way to associate One-To-One relation and to modify both tables.

There's a sample to associate One-To-One relation and to modify both tables in ASP.NET MVC3.
But there is some margin for more CoC. So I describe yet another simple way.

Wednesday, April 20, 2011

Enable ASP.NET Web Site Administration Tool with MariaDB on MVC3

(continued from phosphorescence: Create Simple MVC 3 App with VWDExpress and MariaDB)
If you want to use the system built in ASP.NET with MariaDB, you should do some configurations. This article is referring this article.

Create schema for aspnetdb on MariaDB

Like in this post, create the schema named as aspnetdb and special user for aspnetdb schema.


Monday, April 18, 2011

Create Simple MVC3 App with VWDExpress and MariaDB

(continued from phosphorescence: Prepare MVC 3 with VWDExpress and MariaDB)

Create new MVC 3 project

Launch Visual Web Development 2010 Express, and at first, set the default development web server as IIS Express. [Tools]-[Options]-[Project or Solution]-[Web projdct], turn on the checkbox.
Then, create new MVC 3 project following the wizard. In this sample, I name this project as Mvc3Training. If xunit.net is installed, you can choose test project in the wizard.