如何将页面文件路径转换为http url? [英] How to convert a page file path to http url?

查看:396
本文介绍了如何将页面文件路径转换为http url?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能告诉我,如何将页面文件路径转换为http url?

如果我通过下面的路径
/TempFolder/WebForm.aspx

那么它应该返回
http://www.abc.come/TempFolder/WebForm.aspx

Can any one tell me, How to convert a page file path to http url?

If I pass the path below
/TempFolder/WebForm.aspx

then it should return
http://www.abc.come/TempFolder/WebForm.aspx

推荐答案

显然您的问题还不完整.您处于某种情况下,您会获得相对路径,并且希望使用绝对路径.
发布完整方案将始终帮助您获得正确而准确的答复.

现在,看起来像是相对路径.使用Uri.Absolute路径获取完整路径.
如果需要,您可以使用任何已知文件及其路径来获取完整路径.
甚至一个请求/响应也将具有完整的网址.尝试!
Clearly your question is not complete. You are in a certain scenario where you get relative path and you want to have absolute path to use.
Posting complete scenario would always help you in getting proper and exact replies.

For now, as it looks like, you are having relative path. Use Uri.Absolute path to get the complete path.
If needed, you can use any known file and it''s path to get the full path.
Even a Request/Response would have a complete Url. Try!


您可能会使用ResolveURL.

http://msdn.microsoft.com/en-us/library/system.web.ui.control.resolveurl.aspx [ ^ ]

祝你好运!
You could probably use ResolveURL.

http://msdn.microsoft.com/en-us/library/system.web.ui.control.resolveurl.aspx[^]

Good luck!


我想你可以做到的.喜欢
< a href ="TempFolder/WebForm.aspx">主页</a>
< a href =〜/TempFolder/WebForm.aspx" id ="aDefault" runat ="server"></a>

因此,如果链接为runat ="server",则必须使用相对路径.
I think you can do this, simply. Like
<a href="TempFolder/WebForm.aspx">Home</a>
<a href="~/TempFolder/WebForm.aspx" id="aDefault" runat="server"></a>

so, if the link is runat="server" then you have to use relative path.


这篇关于如何将页面文件路径转换为http url?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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