0

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 
1
  • 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? Commented Jun 4, 2009 at 17:36

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.