When you specify a Web Page while calling the Page.ResolveUrl method, the ResolveUrl method does not return the relative path of the page. This
problem occurs in ASP.NET version 1.1. However, this problem does not occur in
ASP.NET version 1.0.
↑ Back to the top
This problem occurs because the behavior of the ResolveUrl method of the Page class has been changed in Microsoft .NET Framework version 1.1
from the behavior in version 1.0.
Web Controls use the ResolveUrl method to resolve the URL. In ASP.NET version 1.1, when the RelativeUrl parameter contains an absolute URL, the ResolveUrl method returns the URL unchanged.
↑ Back to the top
To work around this problem, use the Page.Server.MapPath property to retrieve the path of the Web page.
↑ Back to the top
Steps to Reproduce the Behavior
- In Microsoft Visual Studio .NET 2003, create a new
ASP.NET Web Application project by using Visual Basic .NET or
Visual C# .NET.
- In Design view, double-click Form1 to view the code for the Page_Load event.
- Add the following code to the Page_Load event:
Visual Basic .NET Sample CodeResponse.Write(Page.ResolveUrl("WebForm1.aspx"))
Visual C# .NET Sample CodeResponse.Write(Page.ResolveUrl("WebForm1.aspx"));
- On the Debug menu, click
Start to run the project. WebForm1.aspx appears without the
path.
↑ Back to the top