locked
Unable to catch the exceptions caused by '|', '"' and ‘~’ symbol in the URL RRS feed

  • Question

  • I have a VB.net website with .Net framework version 1.1.

    I am able to catch all the exceptions and redirect to Custom error screen.

    However if I enter the invalid characters in URL specifically  '|', '"' and '~' it throws "ArgumentException" with message as "?" and not able to redirect this to Custom error screen.

    All other invalid characters and symbols are being handled properly. Custom error screen is set in WEB.config and it is working for all the exceptions.

    Please help me find a way to catch and redirect this exception to Custom error screen.


    • Edited by SharathN Wednesday, March 11, 2015 9:45 AM typo
    • Moved by Carl Cai Thursday, March 12, 2015 5:52 AM asp.net forum is for web Dev issues
    Wednesday, March 11, 2015 9:44 AM

Answers

  • I have a VB.net website with .Net framework version 1.1.

    I am able to catch all the exceptions and redirect to Custom error screen.

    However if I enter the invalid characters in URL specifically  '|', '"' and '~' it throws "ArgumentException" with message as "?" and not able to redirect this to Custom error screen.

    All other invalid characters and symbols are being handled properly. Custom error screen is set in WEB.config and it is working for all the exceptions.

    Please help me find a way to catch and redirect this exception to Custom error screen.


    I would guess for assistance with your Website you may want to post a question in one of the Microsoft ASP.Net forums.

    However your question about entering invalid characters in URL does not make sense to me. Why would you enter invalid characters in a URL? You don't mention how you are doing this or where you are doing this for the Website in question.

    Are you entering invalid characters for a URL in the Websites code? Are you entering invalid characters for a URL by browsing the Website and then providing those invalid characters into a control on a Webpage of the Website?

    You probably need to provide an explanation of exactly what you mean so that a guessing game does not ensue as to what you are doing and then people can perhaps assist you. Otherwise you will just be wasting peoples time as they try to guess whatever it is you are doing unless they have ESP or are a class 5 X-Man or X-Woman with paranormal powers.


    La vida loca

    • Edited by Mr. Monkeyboy Wednesday, March 11, 2015 8:37 PM
    • Proposed as answer by Carl Cai Thursday, March 12, 2015 5:52 AM
    • Marked as answer by Just Karl Tuesday, March 31, 2015 7:57 PM
    Wednesday, March 11, 2015 3:30 PM

All replies

  • I have a VB.net website with .Net framework version 1.1.

    I am able to catch all the exceptions and redirect to Custom error screen.

    However if I enter the invalid characters in URL specifically  '|', '"' and '~' it throws "ArgumentException" with message as "?" and not able to redirect this to Custom error screen.

    All other invalid characters and symbols are being handled properly. Custom error screen is set in WEB.config and it is working for all the exceptions.

    Please help me find a way to catch and redirect this exception to Custom error screen.


    I would guess for assistance with your Website you may want to post a question in one of the Microsoft ASP.Net forums.

    However your question about entering invalid characters in URL does not make sense to me. Why would you enter invalid characters in a URL? You don't mention how you are doing this or where you are doing this for the Website in question.

    Are you entering invalid characters for a URL in the Websites code? Are you entering invalid characters for a URL by browsing the Website and then providing those invalid characters into a control on a Webpage of the Website?

    You probably need to provide an explanation of exactly what you mean so that a guessing game does not ensue as to what you are doing and then people can perhaps assist you. Otherwise you will just be wasting peoples time as they try to guess whatever it is you are doing unless they have ESP or are a class 5 X-Man or X-Woman with paranormal powers.


    La vida loca

    • Edited by Mr. Monkeyboy Wednesday, March 11, 2015 8:37 PM
    • Proposed as answer by Carl Cai Thursday, March 12, 2015 5:52 AM
    • Marked as answer by Just Karl Tuesday, March 31, 2015 7:57 PM
    Wednesday, March 11, 2015 3:30 PM
  • Hello Mr. Monkeyboy,

    One of the security solutions ran a security test by entering the wrong characters in the URL (Few more cases) and there by finding if the site redirects to Custom webpage in case of errors and exceptions or not.

    Our site is redirecting to Custom error page for all the errors and exceptions except when entered '|','"' or '`' in the url.

    Example: If I enter: https://www.somesite.com/NotExists.aspx this get redirected to Custom error screen.

    However If I enter https:////www.somesite.com/NotExi|sts.aspx this goes to Server Error in "/somesite" page.

    Please note, both the URL is invalid, however one redirects to Custom error where another doesn't.

    Thanks for letting me know the lack of clarity in the initial question, hope I made it clear.

    Wednesday, March 11, 2015 3:39 PM
  • Hello Mr. Monkeyboy,

    One of the security solutions ran a security test by entering the wrong characters in the URL (Few more cases) and there by finding if the site redirects to Custom webpage in case of errors and exceptions or not.

    Our site is redirecting to Custom error page for all the errors and exceptions except when entered '|','"' or '`' in the url.

    Example: If I enter: https://www.somesite.com/NotExists.aspx this get redirected to Custom error screen.

    However If I enter https:////www.somesite.com/NotExi|sts.aspx this goes to Server Error in "/somesite" page.

    Please note, both the URL is invalid, however one redirects to Custom error where another doesn't.

    Thanks for letting me know the lack of clarity in the initial question, hope I made it clear.

    I still don't understand the issue. And you should probably be posting the question in one of the ASP.Net forums which I provided a link to in my original post.

    You say you enter a URL in your website. But you make no mention of how that is done. Therefore even if you post a question in one of the ASP.Net forums you will need to explain what you mean by entering a URL in your Website.

    For example. "We have a website. A user can browse to the website with a WebBrowser. Then in a textbox on the website they can enter a URL (for whatever reason your website would allow a user browsing your website with a webbrowser to want to enter some URL for some reason into a textbox at your website) and select a button (to do who knows what) and we need to validate the URL does not contain invalid characters."

    Maybe these links can help or not.

    Validator.Url Method

    PathIsURL function

    Pinvoke.Net - pathisurl (shlwapi)

    Uri.TryCreate Method

    I suppose you could even use Regex to validate a URL based on Regex patterns that you should be able to find on the net for doing so with Visual Basic. But I would suppose you would want to provide whoever is placing invalid URL's on the website with the result displaying the invalid URL and which characters within it are invalid maybe.

    I suspect you could even try to validate a URL with a DNS by finding out if it exists or not.


    La vida loca

    Wednesday, March 11, 2015 8:49 PM