Why browser URL cannot end with .com?

2019-06-01 04:18发布

In my article site some users decided to have their eMail address instead of user name The problem starts when i'm trying to redirect to a page using RouteData and the URL ends with ".com" , for example "example@gmail.com" is a valid username so his personal page will be

http://www.mysite/user/example@gmail.com

live example

As you can see the it gets redirect to home page and relative path gets messed up, so images doesn't show

Can someone tell me why browsers don't like routedata in their url ending with .com ? If you try ".net" or ".org" it will work, that's the issue with ".com" ?

1条回答
爷的心禁止访问
2楼-- · 2019-06-01 04:46

In Windows, the .com extension is used to denote a type of executable file. Your question is tagged as asp.net - so I assume you are using IIS. IIS does not manage virtual directory names containing executable extensions such as: .vbs, .com, .exe, etc.

When a virtual directory name ends with an executable extension (such as .com, .exe, .dll, or .sh), the files in this virtual directory cannot be viewed with a Web browser. For more info, see here.

One option you have is to simply replace . with an underscore _ for personal pages. So your example above would be: http://www.mysite/user/example@gmail_com

查看更多
登录 后发表回答