开发者

ASP.NET - Omitting the question mark character

I was wondering if it is possible to omit the question mark in the URL after the aspx page and still be able to parse characters in the URL. For example, let's say I have this URL: http://localhost/?specialparam,story:extra. When I navigate to the page it displays correctly and I'm able to parse my specialparam and story parameter. Now if I enter in the URL by omitting the '?' character as http://localhost/specialparam,s开发者_如何学运维tory:extra then I get the page not found error.

A little backgound on why I am doing it this way. I want to be able to shorten the URL sort of how they do it on bit.ly but be able to pass some special parameters that my .aspx page can parse.

I understand that with the '?' character in the URL it will go to the default document specified in IIS. Can I get some suggetions on if this is even possible to remove the '?' character or if URL Rewriting will help.

Thank you for your help.


MVC 3 would do just the trick.


The ? character designates the beginning of the query string, so you can hardly remove it if you want to keep using query strings. On the other hand, if you do remove it, you can simply refer to Request.PathInfo, which will give you all the data after the filename, but before the query string. For example:

http://localhost/Default.aspx/Your/Path/Info

The path info is /Your/Path/Info. However, you would be required to include the .aspx file since otherwise the server wouldn't be able to distinguish from a real file on the web server.

(Also, the ? character has absolutely nothing to do with default documents in IIS)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜