[Mono-aspnet-list] Mapping route values after first POST

gajcz gajczewski at gmail.com
Wed Sep 28 00:00:00 EDT 2011


I found a strange problem developing MVC 3 project. Since I implemented
signing-in mechanism the rest of my website started to crash.
When I'm not signed-in everything works fine, but after I fill and post
LogOn form I'm getting an exception on any page uses route values (e.g.
/Home/About/*1*). It goes:

*"The parameters dictionary contains a null entry for parameter 'id' of
non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult
About(Int32)' in 'TestApp.Controllers.HomeController'. An optional parameter
must be a reference type, a nullable type, or be declared as an optional
parameter. Parameter name: parameters"*

Searching for a reason I created new ASP.NET MVC 3 Web Application in Visual
Studio and I made only 3 simple changes:

*1*. I changed AccountController.LogOn Post method to redirect to

*public ActionResult LogOn(LogOnModel model)
    return RedirectToAction("Index", "Home");

*2*. I added id parameter to Home/About:

*public ActionResult About(int id)
    return View();
*3*. I changed link to About in _Layout.cshtml to:

*@Html.ActionLink("About", "About", "Home", new { id = 1 }, null)*

After these changes (+ adding some references for Linux) the application
crashes on Linux but works on Windows.
1) Home -> LogOn -> POST -> About (crash)
2) Home -> About -> LogOn - > POST (model is null :|) -> About (works) ->

I removed the 'id' parameter of Action method and set it by:
var id = Convert.ToInt32(RouteData.Values["id"]);
and it works, but it's not a solution to remove all parameters (not only
simple 'int') from controllers' actions.

This is really strange for me. Can anyone confirm this behaviour or deny?
Maybe I've got something wrong with my Linux configuration or with these
references...? Please help.

Versions I use: 
- OpenSUSE 11.3 (from vmware image)
- Mono 2.10.2 (default)

View this message in context: http://mono.1490590.n4.nabble.com/Mapping-route-values-after-first-POST-tp3849969p3849969.html
Sent from the Mono - ASP.NET mailing list archive at Nabble.com.

More information about the Mono-aspnet-list mailing list