Closed Thread
Results 1 to 4 of 4

Thread: '?' Is an illegal character in a URL?

  1. #1
    Dodi300 is offline Newbie
    Join Date
    Jan 2010
    Posts
    2
    Rep Power
    0

    '?' Is an illegal character in a URL?

    Helloooo.
    I need a solution for this.
    Visual Studio says that the character '?' is illegal in a path.
    I'm using the '?' in a URL.

    Is there anyway to replace the '?' but still keep the URL working.
    I've tried using "string.replace" but that didn't work.

    Any ideas?

    Thanks.

    This is the code which uses the URL.
    Code:
        public void StartAll()
        {
            int i = 0;
            foreach (var link in Links)
            {
                try
                {
                    var uri = new Uri(link);
                }
                catch (Exception exception)
                {
                    OnError(i, "Error: Job ID(" + i + ") " + exception.Message);
                    i++;
                    continue;
                }
    
                var backgroundWorker = new BackgroundWorker() { WorkerReportsProgress = true, WorkerSupportsCancellation = true };
                backgroundWorker.DoWork += (backgroundWorker_DoWork);
                backgroundWorker.ProgressChanged += (backgroundWorker_ProgressChanged);
                backgroundWorker.RunWorkerCompleted += (backgroundWorker_RunWorkerCompleted);
                var downloadParam = new QDownloadParam() { ID = i, FileDirectory = FileDirectory, Link = link, Password = Password, Username = Username, Worker = backgroundWorker };
                Jobs.Add(downloadParam);
                OnChanged(i, "Job ID(" + i + ") Added.");
                backgroundWorker.RunWorkerAsync(downloadParam);
                i++;
            }
            OnlineJobs = Jobs.Count;
    
        }

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    QuackWare is offline Learning Programmer
    Join Date
    Jan 2010
    Posts
    95
    Rep Power
    8

    Re: '?' Is an illegal character in a URL?

    Try using strings instead of vars.

  4. #3
    lobo521 is offline Learning Programmer
    Join Date
    Jan 2010
    Posts
    57
    Rep Power
    8

    Re: '?' Is an illegal character in a URL?

    I tried like that and no exceptions.

    var uri = new Uri("http://forum.codecall.net/newreply.php?do=newreply&noquote=1&p=235898");

    Uri allows "?" only in right places. Show exact link that doesn't work.
    BTW i don't see usage of your uri variable (only assignment).

  5. #4
    Davide's Avatar
    Davide is offline Programming God
    Join Date
    Dec 2009
    Location
    Manchester, UK
    Posts
    507
    Blog Entries
    8
    Rep Power
    11

    Re: '?' Is an illegal character in a URL?

    This seems to be working:
    var uri = new Uri("http://forum.codecall.net/newreply.php?do=newreply&noquote=1&p=235898");

    What is the exact error that you receive?
    Are you a newbie programmer trying to learn C#? Check out my small tutorial: Visual C# Programming Basics

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 7
    Last Post: 10-12-2011, 06:24 AM
  2. Illegal character
    By Tank314 in forum Java Help
    Replies: 4
    Last Post: 03-12-2011, 06:33 PM
  3. Would it be illegal?
    By toxifyshadow in forum Business and Legal
    Replies: 4
    Last Post: 03-14-2010, 01:15 PM
  4. Being annoying is now illegal in Brighton, MI
    By nicckk in forum The Lounge
    Replies: 12
    Last Post: 12-29-2008, 06:56 AM
  5. Replies: 16
    Last Post: 09-11-2008, 03:46 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts