0

Hi, I have the following route

        routes.MapRoute(
            "Segnalazioni_CercaSegnalazioni",
            "Segnalazioni/CercaSegnalazioni/{flag}",
            new { controller = "Segnalazioni", action = "CercaSegnalazioni", flag = 7 }
        );

that maps to the following methon of the class SegnalazioniController:

    public ActionResult CercaSegnalazioni(int flag)
    {
        ViewData["collezioneSegnalazioni"] = Models.Segnalazioni.Recupera(flag);
        System.Xml.Linq.XElement x = (System.Xml.Linq.XElement)ViewData["collezioneSegnalazioni"];
        return View("Index");
    }

How come the link http://localhost:1387/Segnalazioni/CercaSegnalazioni/1 gives me the error

The parameters dictionary contains a null entry for parameter 'flag' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult CercaSegnalazioni(Int32)' in 'RecuperoPagatiMvc.Controllers.SegnalazioniController'. To make a parameter optional its type should be either a reference type or a Nullable type.
Nome parametro: parameters

Thanks

flag

59% accept rate
sounds to me like you're not hitting that route. if you move the route posted to the top of your route table does it work? – John Sheehan Jun 4 '09 at 17:36

2 Answers

1

Post all your routes. It sounds like your URL is being handled by a different route than this one. Remember, the order you list your routes does matter. Therefore, if you have another route BEFORE this one that this URL can map to, it will.

link|flag
0

MvcContrib contains route debugger. Use it and you'll see which route is called for this url. Here are some instructions how to enable it

link|flag

Your Answer

get an OpenID
or
never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.