开发者

ASP.NET MVC URLs - Correct approach

Currently my project has a page domain/cocktail which displays a list of all cocktails. If user wants to filter the list he can choose sorting order, cocktail's starting letter and strength. So url will look like domain/cocktail?letter=B&sort=nu&strength=2&page=4.

As I've read it is not the best choice to use such urls. What approach can you suggest to get SEO-friendly URLs with t开发者_如何学Che same functionality.


ASP.NET MVC applications use the ASP.NET routing system, which decides how URLs map to particular controllers and actions.

Under default routing system when a browser requests http://yoursite/Home, it gets back the output from Controller's action method. Therefore if you use CoctailList action method to derive the list from backend, user will need to point at http://yoursite/Controller/CoctailList


In your situation, I would POST the search criteria, but I would put the page on end of the URL like:

domain/cocktail/2
domain/cocktail/3

You can post the data by creating a JSON object:

var viewModel = new Object();
viewModel.Letter = "B";
viewModel.Sort = "nu";
$.post("/domain/cocktail/" + page, viewModel, function () { });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜