Dear all i have a controller called data, with single method index which accept a string parameter. the call to this action must be like the following .
As you can see from the above sample any thing after data/ should be the parameter value of index method (1202-0036-46?pump_house_fault=1361615427.6|1), please note the value before "?" it will change so it is not a constant querystring
key
how i can configure mvc application for such kind of routing.. keep in mind anything after data/ should be the parameter for my index action methode and the fromat cannot be changed...
You can use above route to route your request to controller and action and have param as argument as part of your action method. being different query string key I doubt that you can map it directly to your action method parameter, I guess
you can right a model which will have these keys and then it will bind it to appropriate values. But make sure your query string Key is one of the property in model.
binson143
Member
424 Points
179 Posts
How to configure route for this url
Feb 28, 2013 10:56 AM|LINK
Dear all i have a controller called data, with single method index which accept a string parameter. the call to this action must be like the following .
/data/1202-0036-46?pump_house_fault=1361615427.6|1
/data/1241-0029-46?jockey_pump_fault=1361615427.6|0
/data/1229-0044-46?vesda_4_isolation=1361615427.6|0
/data/1246-0032-46?fire_alarm_system_common_alarm=1361615427.6|0
/data/1202-0036-46?intruder_system_fault=1361615427.6|1
/data/1229-0044-46?intruder_system_armed=1361615427.6|0
/data/1120-0002-46?diesel_pump_1_running_L1D7=1361615427.6|1
As you can see from the above sample any thing after data/ should be the parameter value of index method (1202-0036-46?pump_house_fault=1361615427.6|1), please note the value before "?" it will change so it is not a constant querystring key
how i can configure mvc application for such kind of routing.. keep in mind anything after data/ should be the parameter for my index action methode and the fromat cannot be changed...
CPrakash82
All-Star
18284 Points
2841 Posts
Re: How to configure route for this url
Feb 28, 2013 11:37 AM|LINK
routes.MapRoute("Default", "Data/{param}", new { controller = "Data", action = "Index", param = "" },
You can use above route to route your request to controller and action and have param as argument as part of your action method. being different query string key I doubt that you can map it directly to your action method parameter, I guess you can right a model which will have these keys and then it will bind it to appropriate values. But make sure your query string Key is one of the property in model.
danellos
Member
166 Points
24 Posts
Re: How to configure route for this url
Feb 28, 2013 11:39 AM|LINK
It sounds to me like you are looking for a catch-call segment since it looks like there can be any number of queries here in the URL.
Does this perhaps help you?
http://erraticdev.blogspot.com/2011/01/custom-aspnet-mvc-route-class-with.html