开发者

Facebook page style urls in Asp.Net MVC

开发者 https://www.devze.com 2023-01-19 18:41 出处:网络
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/

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

精彩评论

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