views:

26

answers:

1

i konw that you can have a period in a querystring parameter, but you cant specify a period in variable names in .net.

The following code obviously does not work, but my external system uses the period in the names. Is there a way to do this?

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index(string hub.mode)
{
    return View();
}
+2  A: 

You could read the value directly from the Request hash:

[HttpPost]
public ActionResult Index()
{
    string hubMode = Request["hub.mode"];
    return View();
}

or using an intermediary class:

public class Hub
{
    public string Mode { get; set; }
}

[HttpPost]
public ActionResult Index(Hub hub)
{
    string hubMode = hub.Mode;
    return View();
}

As you will notice . has special meaning for the ASP.NET MVC default model binder.

Darin Dimitrov
worked good, thanks
wcpro