我想在url中传递一个参数,但localhost服务器告诉它是坏网址。我可以让他们在MVC 3中工作吗
网址是
http://localhost:6251/time/saturdau/first/second//nextparameter
你可以看到第三个参数在这里是空白的。当第4个参数通过而没有通过第3个参数时,此请求是否可以工作。
我的工作是做什么的。
答案 0 :(得分:0)
这是不允许的。您可以使用可选参数,但它们必须是URL中的最后一个段。中间不能有可选参数。
答案 1 :(得分:0)
所以不要让它看起来像这样
http://localhost:6251/time/saturdau/value1/34//70
这样做
http://localhost:6251/time/saturdau/value1/34/my_conventional_null_indicator/70
但最好的方法仍然是传统方式
http://localhost:6251/time/saturdau?param1=value1¶m2=34¶m3=¶m4=70
或更好的方法是最大化RouteValueDictionary的功能。