Scheduled Tasks and redirecting problem

Discussion in 'Getting started' started by parzapesc12, Dec 17, 2009.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I use scheduled tasks for my web application, that using method to read information from other sites using http protocol. But it gave me the following error 301 - Moved Permanently. But also when I try to use other application that only using some simple methods scheduled task bring me the same error.

    Please help me to solve this problem.
     
  2. mjp

    mjp

    The error 301 - Moved Permanently error usually also returns an alternate URL that the server believes the file has been moved to. A web browser will redirect to that URL automatically (which is why you've probably never seen it in a browser), but it sounds like your application does not.

    Basically, 301 means the file you are requesting is not at the URL you are requesting it from.
     
  3. Thank you for your answer.

    I use 10 .dll files and one .pdb file, and use HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(URL) and 22 classes that located in AppCode directory. Are ther any problem with the above mentioned issues?
     
  4. mjp

    mjp

    The problem is the remote server. You are asking the server for content that it does not have. So the server is saying, "Here, go to this URL to get the content you are looking for," but the scheduled task will not go to that URL (it will not follow a redirect).

    The easiest thing to do would be to:
    • Copy the URL from your scheduled task
    • Stick it in a web browser
    • See where it redirects to
    • Copy that new URL (the one you are redirected to)
    • Put the new URL in your scheduled task
     
  5. I'm sorry about that and I didn't doubt you. I'm just telling you how it looks from here just in case it helps.
     
  6. Just one thought - instead of using a URL without the page specified and relying on the IIS default document config, have you tried assigning the full path to the page in the scheduled task config?

    In the one scheduled task I have setup, I have it requesting a page with the name default.aspx but I do have the full path to the page specified. Maybe the task scheduler web page requestor is doing something strange when the page filename is not explicitly specified.
     
  7. Bruce

    Bruce DiscountASP.NET Staff

    i checked the scheduled task log and it indeed logged a 301 (I also cross reference the HTTP log).
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page