何时使用路由规则VS查询字符串参数与asp.net的MVC [英] When to use a routing rule vs query string parameters with asp.net mvc

查看:93
本文介绍了何时使用路由规则VS查询字符串参数与asp.net的MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在考虑用ASP.NET MVC项目和路由与参数的主题向前走了过来。

We're considering moving forward with a ASP.NET MVC project and the subject of routing versus parameters came up.

看到如何,你可以轻松地设置一个或两个在ASP.NET MVC的结合,是否有我应该知道使用一个或时的任何考虑其他?

Seeing as how you can easily set up either or a combination of both in ASP.NET MVC, are there any considerations that I should be aware of when using one or the other?

推荐答案

我会建议保持你的网址尽可能干净,并尝试使用途径只要有可能。你应该尝试做的RESTful URI的将信息传达给用户。例如:

I would recommend keeping your URL's as clean as possible and to try and use routes whenever possible. You should try and make RESTful URI's that will convey information to the user. For example:

www.yourdomain.com/Products/Sports/Clothing

www.yourdomain.com/Products?Department=Sports&SubDepartment=Clothing 

如果使用一吨的查询字符串的话,就不会成为一个干净URI和较少的信息被传送到用户。

If you use a ton of query strings then it won't be a clean URI and less information is conveyed to the user.

随着中说,我们的团队确实使用的查询字符串使用jQuery AJAX类型的请求。这是因为这些的URI是在我们的标记,并且不会在浏览器窗口中可以​​看出。这有助于保持我们的Global.asax小一些,因为它不会让污染一吨的路线。

With that said, our team does use query strings for ajax type requests using jquery. This is because these URI's are in our markup and won't be seen in the browser window. This has helped keep our global.asax a little smaller since it won't get polluted with a ton of routes.

这篇关于何时使用路由规则VS查询字符串参数与asp.net的MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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