开发者

Facebook page style urls in Asp.Net MVC

How would I write a route in Asp.Net mvc to handle a url like this one for a Facebook page:

http://graph.facebook.com/http://codedojoboise.开发者_StackOverflow中文版com/

I tried this route but get a 400 Bad Request error when I try to run it.

 routes.MapRoute(

            "LinkPreview",
            "LinkPreview/{path}",
            new {controller = "LinkPreview", action = "Get"});


The characters : and / are being treated like parameter separators and so the route isn't matching. Try LinkPreview/{*path} which will tell it to use all the following characters as part of the parameter.


Handling such characters in ASP.NET is a real PITA. You may checkout this or base64 encode it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜