Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7776855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:59:05+00:00 2026-06-01T17:59:05+00:00

Trying to follow this MSDN tutorial to get a web response but not getting

  • 0

Trying to follow this MSDN tutorial to get a web response but not getting any response back, so wondering if I can use anything else except default or network credentials for sending a web request.

I am using it in a Sharepoint Custom Timer Job installed using a Feature Receiver, here’s the code,

Timer Job class with execute method

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using System.Diagnostics;

namespace EmailJob.FeatureCode
{
    class SharePointWarmupJob : SPJobDefinition
    {
        private const string JOB_NAME = "Email Job";

        public SharePointWarmupJob() : base() { }

        public SharePointWarmupJob(SPWebApplication webApp)
            : base(JOB_NAME, webApp, null, SPJobLockType.ContentDatabase)
        {
            this.Title = JOB_NAME;
        }

        public override void Execute(Guid targetInstanceId)
        {
            Debug.Assert(false);

            if (this.WebApplication.Sites.Count > 0)
                WarmUpSharePointSite(this.WebApplication.Sites[0]);
        }

        private void WarmUpSharePointSite(SPSite siteCollection)
        {
            System.Net.WebRequest request = System.Net.WebRequest.Create(siteCollection.Url);
            request.Credentials = System.Net.CredentialCache.DefaultCredentials;
            request.Method = "GET";

            System.Net.WebResponse response = request.GetResponse();
            response.Close();
        }
    }
}

Feature Receiver class

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using EmailJob.FeatureCode;

namespace EmailJob
{
    class EmailJobFeature : SPFeatureReceiver
    {
        private const string JOB_NAME = "Email Job";

        public override void FeatureInstalled(SPFeatureReceiverProperties properties)
        {
            throw new NotImplementedException();
        }

        public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
        {
            throw new NotImplementedException();
        }

        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;
            if (webApp == null)
                throw new NotImplementedException("Error obtaining reference to Web application");

            foreach (SPJobDefinition job in webApp.JobDefinitions)
                if (job.Name == JOB_NAME) job.Delete();

            SharePointWarmupJob warmupJob = new SharePointWarmupJob(webApp);

            SPMinuteSchedule schedule = new SPMinuteSchedule();
            schedule.BeginSecond = 0;
            schedule.EndSecond = 59;
            schedule.Interval = 5;

            warmupJob.Schedule = schedule;

            warmupJob.Update();
        }

        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;
            if (webApp == null)
                throw new NotImplementedException("Error obtaining reference to Web application");

            foreach (SPJobDefinition job in webApp.JobDefinitions)
                if (job.Name == JOB_NAME) job.Delete();

            throw new NotImplementedException();
        }
    }
}

When I try to debug, it gives no response back at code line

"System.Net.WebResponse response = request.GetResponse();"

This is my VPC and am logged as Administrator, I even commented out credentials code line or tried network credentials but it just doesn’t seems to work.

Oh yes when i try to test code in Console app, it says the credentials properties are null except encrypt = true

Cheers !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:59:07+00:00Added an answer on June 1, 2026 at 5:59 pm

    From msdn, Credentials is of type ICredentials so you need an implementation.

    Fortunately, they also state you should use a NetworkCredentials object or CredentialCache 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to follow this tutorial but with the immediate window in vs2010 rather
I am trying to follow this tutorial and I get the following error which
I am trying to follow this tutorial http://damianm.com/tech/nhibernate-mvc-and-ninject/ but I am running into some
I'm not a much of a programmer, but I'm trying to follow this 4
I am trying to follow this tutorial on how to connect to a database
I want to include Core Location and I'm trying to follow this tutorial: http://www.mobileorchard.com/hello-there-a-corelocation-tutorial/
I am new to maven and I am trying to follow this example but
I am trying to follow this example from MSDN: http://msdn.microsoft.com/en-us/library/a1hetckb.aspx I think i'm doing
Trying to follow this tutorial. Autotest fails with this error message: sg $autotest loading
I'm trying to follow this tutorial http://eloquentjavascript.net/chapter8.html It mentions a function inPlacePrinter . I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.