Changes in ResolveUrl and ResolveClientUrl under. NET Framework 4

Source: Internet
Author: User

I think everyone should use ResolveUrl and ResolveClientUrl. This document is not described here. If you have never used it, click here.

In MSDN, The ResolveUrl and ResolveClientUrl under. NET Framework 4 and. NET Framework 3.5 are the same, but are they true?

Of course, the answer is different. If they are the same, there will be no such essay.

Run the following code:

 

Code

Private void TestUrl ()
{

RelativeUrl = @"~ \ 11 \ 22. aspx ";
ParseUrlResult (relativeUrl );

RelativeUrl = @"~ /11/22. aspx ";
ParseUrlResult (relativeUrl );

RelativeUrl = @"~ \ 11 \ 22. aspx? 1 = 1 ";
ParseUrlResult (relativeUrl );

RelativeUrl = @"~ \ 11 \ 22. aspx? Http://contoso.com ";
ParseUrlResult (relativeUrl );

RelativeUrl = @"~ /11/22. aspx? Http://contoso.com ";
ParseUrlResult (relativeUrl );

RelativeUrl = @ "... \ 11 \ 22. aspx? ";
ParseUrlResult (relativeUrl );

RelativeUrl = @ "... \ 11 \ 22. aspx? ";
ParseUrlResult (relativeUrl );

RelativeUrl = @ "http://www.cnblogs.com/../11/22.aspx? ";
ParseUrlResult (relativeUrl );

RelativeUrl = @ "http://contoso.com ";
ParseUrlResult (relativeUrl );

}

Private void ParseUrlResult (string relativeUrl)
{
Response. Write (string. Format ("raw URL: {0}", relativeurl ));
Response. Write ("<br/> ");
Try
{
Response. Write (string. Format ("resolveurl: {0}", this. resolveurl (relativeurl )));
}
Catch (exception ex)
{
Response. Write (string. Format ("<font color = 'red'> ResolveUrl: {0} </font>", ex. Message ));
}
Response. Write ("<br/> ");
Try
{
Response. Write (string. Format ("ResolveClientUrl: {0}", this. ResolveClientUrl (relativeUrl )));
}
Catch (exception ex)
{
Response. Write (string. Format ("<font color = 'red'> resolveclienturl: {0} </font>", Ex. Message ));
}
Response. Write ("<br/> ");
Response. Write ("<br/> ");
}

 

 

 

The following are the results under. NET Framework 4: The results under. NET Framework 3.5 are as follows:

In the comparison, it is different. Obviously in. NET Framework 4, ResolveClientUrl can be used to input parameters with absolute addresses. The ResolveUrl can also be used to input parameters containing absolute addresses, but the forward and backward slashes are distinguished.

Obviously, the program was changed, but only. NET Framework 4 was added to MSDN. The specific content was not changed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.