I am in a situation where i want to define the parameter type inside the method. But if i do something like this:
public class UserModel
{
public string InputName { get; set; }
}
[HttpPost]
public ActionResult Index(object obj)
{
UserModel test = obj as UserModel;
ViewBag.Test = test.InputName;
return View();
}
The naming convention, that there is supposed to be in my obj
when posting a form, does not take place? I think.
I wanna do this, because the obj
type is located elsewhere.
Can this be done somehow? Do I need to overwrite something?
Edit: - Another way of addressing my problem.
When you post a form in a MVC web application. You receive the data by declaring a parameter type in your ActionResult. And here a naming convention takes place right? But what if i don't know the parameter type right away? How can I declare the parameter type later inside the ActionResult method and get the naming convention to happen there?
Hope it makes sense, and sorry for my English!
Thank you for your suggestions! I found another way to approach my problem. And now i am stuck here instead :)