我可以用逗号网址? [英] Can I use commas in a URL?

查看:388
本文介绍了我可以用逗号网址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常使用URL重写,以内容ID传递给我的网站,所以这

I typically use URL rewriting to pass content IDs to my website, so this

 Foo.1.aspx

改写为

 Foo.aspx?id=1

有关特定的应用程序,我需要在多个ID传递给单个页面,所以我改写的东西接受这一点:

For a specific application I need to pass in multiple IDs to a single page, so I've rewritten things to accept this:

 Foo.1,2,3,4,5.aspx

这在卡西尼(内置特设网站为Visual Studio服务器)的作品不错,但给了我当我尝试在上线的服务器上运行IIS的Internet Explorer无法显示该网页。这是一个IIS限制吗?如果我只是使用破折号或下划线代替逗号?

This works fine in Cassini (the built-in ad hoc web server for Visual Studio) but gives me "Internet Explorer cannot display the webpage" when I try it on a live server running IIS. Is this an IIS limitation? Should I just use dashes or underscores instead of commas?

推荐答案

我记得URL路由默认情况下,首先检查文件是否存在,和逗号都没有合法的文件名,这是parhaps为什么你得到错误。 IIS可能有遗留code的中止,才可以得到ASP.NET处理该请求。

I recall that Url Routing by default first checks to see if the file exists, and commas are not legal in filenames, which is parhaps why you are getting errors. IIS may have legacy code that aborts the request before it can get to asp.net for processing.

斯科特Hanselman的<一个href=\"http://www.hanselman.com/blog/PlugInHybridsASPNETWebFormsAndASPMVCAndASPNETDynamicDataSideBySide.aspx\">blog帖子谈到这一点,可能与您无关。

Scott Hanselman's blog post talks a bit about this and may be relevant for you.


作为一般性评论:URL重写通常用来使一个url友好,易记

As general comment: Url rewriting is typically used to make a url friendly and easy to remember.

〜/ page.aspx?ID = 1,2,3,4 既不是比〜/页/ 1-2更糟,也不好-3-4.aspx :都是很难用,为什么要经过额外的努力?避免产生新的URL形式只是因为你可以。用户,帮助台,和其他开发商只会混淆。

~/page.aspx?id=1,2,3,4 is neither worse nor better than ~/page/1-2-3-4.aspx : both are difficult to use so why go through the extra effort? Avoid creating new url forms just because you can. Users, help desk, and other developers will just be confused.

URL重写最好利用变换

Url rewriting is best utilized to transform

~/products/view.aspx?id=1
~/products/category.aspx?type=beverage

~/products/view/1
~/products/category/beverage

这篇关于我可以用逗号网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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