I know ASP.NET does this automatically, but for some reason I can't seem to find the method.
Help anyone? Just as the title says.
If I do a Response.Redirect("~/Default.aspx"), it works, but I don't want to redirect the site. I just want the full URL.
Can anyone help me out?
For the "/#{path}/Default.aspx" part, use:
Page.ResolveUrl("~/Default.aspx")
If you need more:
Request.Url.Scheme + "://" + Request.Url.Host + ":" + Request.Url.Port
在Web控件中,方法是ResolveUrl("~/Default.aspx")
看一下VirtualPathUtility类。
There are at least three ways of doing this. I asked if there was any difference, but I didn't get any answer.
Here's an article that explains the difference between the various ways to resolving paths in ASP.NET -
这是我使用的:
Response.Redirect(Response.ApplyAppPathModifier("~/default.aspx"))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.