本文介绍了提取url参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
i是mvc的新手....
例如:www.abc .com / def / hij
如何读取url参数... def,hij
Hi,
i am newbie to mvc....
eg: www.abc.com/def/hij
how to read the url parameters...def,hij
推荐答案
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 :
public ActionResult Index(string Parameter1, string Parameter2)
{
}
希望这对你有所帮助。
问候,
RK
Hope this helps you a bit.
Regards,
RK
这篇关于提取url参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!