且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将页面文件路径转换为http url?

更新时间:2023-02-25 15:31:31

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

现在,看起来像是相对路径.使用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.