提取url参数 [英] extract the url parameters

查看:106
本文介绍了提取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

推荐答案

Poorni,



如果你想读取参数,那么你需要在Route.Config中添加如下所示的参数完成。

Poorni,

If you want to read the parameters then you need to add parameters like below in Route.Config if its not already done.
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参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆