Click here to Skip to main content
15,893,663 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

i am newbie to mvc....

eg: www.abc.com/def/hij


how to read the url parameters...def,hij
Posted
Comments
Maciej Los 3-Jan-14 4:48am    
What kind of url parameters? I don't see it.
Query string[^]
♥…ЯҠ…♥ 3-Jan-14 5:36am    
Poorni, those are not parameters in MVC, it is directory structure. Parameters follow after '?' in the URL, It can be done even without ? in the URL for that you need to modify Route.Config file

1 solution

Poorni,

If you want to read the parameters then you need to add parameters like below in Route.Config if its not already done.
C#
routes.MapRoute(
            "TestPage",                                              // Route name
            "{controller}/{action}/{Parameter1}/{Parameter2}",                           // URL with parameters
            new { controller = "Home", action = "Index", Parameter1 = "", Parameter2= "" }  // Parameter defaults
        );

Once added, you can read the parameters very easily using
In Home Controller :
C#
public ActionResult Index(string Parameter1, string Parameter2)
{

}


Hope this helps you a bit.

Regards,
RK
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900