none
What does Server.Urlencode do? RRS feed

  • Question

  • Hi, can anyone tell what does Server.Urlencode do? And how can we use it?
    Thanks!! http://gurunguns.wordpress.com
    Friday, July 2, 2010 1:43 PM

Answers

  • Hi GurunGuns,

         I'm glad to see you.  As we all know Page.Server property is a HttpServerUtility's instance, so it is defined in the HttpServerUtility class.

     please refer to

         http://msdn.microsoft.com/en-us/library/ms525738(VS.90).aspx (Server.URLEncode Method)

         http://msdn.microsoft.com/en-us/library/system.web.httpserverutility.urlencode(v=VS.71).aspx(HttpServerUtility.UrlEncode Method)

       http://msdn.microsoft.com/en-us/library/system.web.httpserverutility.urldecode(v=VS.71).aspx(HttpServerUtility.UrlDecode Method)

     Hope this will help you!  

       If you still have any doubt and concern about this issue, please let me know. If I misunderstood you, please kindly elaborate your question.


    Please Mark as Answered If this is helpful Or Un-Mark as Answered if it is not helpful.

    Best Regards,
    Yan Jun
    Microsoft Online Community Support

    Monday, July 5, 2010 7:43 AM
    Moderator
  • URL encoding ensures that all browsers will correctly transmit text in URL strings. Characters such as a question mark (?), ampersand (&), slash mark (/), and spaces might be truncated or corrupted by some browsers. As a result, these characters must be encoded in <a> tags or in query strings where the strings can be re-sent by a browser in a request string.

    UrlEndcode is a convenient way to access the HttpUtility.UrlEnCode method at run time from an ASP.NET application. Internally, UrlEnCode uses HttpUtility.UrlEncode to encode strings.

    for example -

    String MyURL;
    MyURL = "http://www.contoso.com/articles.aspx?title=" + Server.UrlEncode("ASP.NET Examples");

    Response.Write("<a href=" + MyURL + "> ASP.NET Examples </a>");

     

    regards

    jayant

    Friday, July 2, 2010 1:52 PM

All replies

  • URL encoding ensures that all browsers will correctly transmit text in URL strings. Characters such as a question mark (?), ampersand (&), slash mark (/), and spaces might be truncated or corrupted by some browsers. As a result, these characters must be encoded in <a> tags or in query strings where the strings can be re-sent by a browser in a request string.

    UrlEndcode is a convenient way to access the HttpUtility.UrlEnCode method at run time from an ASP.NET application. Internally, UrlEnCode uses HttpUtility.UrlEncode to encode strings.

    for example -

    String MyURL;
    MyURL = "http://www.contoso.com/articles.aspx?title=" + Server.UrlEncode("ASP.NET Examples");

    Response.Write("<a href=" + MyURL + "> ASP.NET Examples </a>");

     

    regards

    jayant

    Friday, July 2, 2010 1:52 PM
  • Hi GurunGuns,

         I'm glad to see you.  As we all know Page.Server property is a HttpServerUtility's instance, so it is defined in the HttpServerUtility class.

     please refer to

         http://msdn.microsoft.com/en-us/library/ms525738(VS.90).aspx (Server.URLEncode Method)

         http://msdn.microsoft.com/en-us/library/system.web.httpserverutility.urlencode(v=VS.71).aspx(HttpServerUtility.UrlEncode Method)

       http://msdn.microsoft.com/en-us/library/system.web.httpserverutility.urldecode(v=VS.71).aspx(HttpServerUtility.UrlDecode Method)

     Hope this will help you!  

       If you still have any doubt and concern about this issue, please let me know. If I misunderstood you, please kindly elaborate your question.


    Please Mark as Answered If this is helpful Or Un-Mark as Answered if it is not helpful.

    Best Regards,
    Yan Jun
    Microsoft Online Community Support

    Monday, July 5, 2010 7:43 AM
    Moderator