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

  • SEARCH
  • Home
  • 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 8826697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:12:14+00:00 2026-06-14T07:12:14+00:00

I ran a console application yesterday to send and receive web request and web

  • 0

I ran a console application yesterday to send and receive web request and web response and it works fine. Today I’m testing the same method on my form application and I get the error WebRequest Does Not Contain A Definition For Create. All my imports are the same. It’s a bit strange and I don’t know what I’m doing wrong. This is the code to my console application:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HtmlAgilityPack;
using System.Net;
using System.IO;

namespace WebrequestCsharp
{
    class Program
    {
        static void Main(string[] args)
        {
            StreamWriter sw;
            sw = File.AppendText("c:\\Temp\\webresponse.txt");
            //Create a Web-Request to an URL
            HttpWebRequest HWR_Request = (HttpWebRequest)WebRequest.Create("http://www.hitta.se/ericsson/företag_och_personer");

            //Send Web-Request and receive a Web-Response
            HttpWebResponse HWR_Response = (HttpWebResponse)HWR_Request.GetResponse();

            //Translate data from the Web-Response to a string
            Stream S_DataStream = HWR_Response.GetResponseStream();
            StreamReader SR_DataStream = new StreamReader(S_DataStream, Encoding.UTF8);
            string s_ResponseString = SR_DataStream.ReadToEnd();
            S_DataStream.Close();
            sw.WriteLine(s_ResponseString);
            sw.Flush();
            sw.Close();

            HtmlDocument doc = new HtmlDocument();
            doc.Load("c:\\Temp\\webresponse.txt");
            Console.ReadKey();
        }


    }
}

And this is my form application that cannot accept my Create:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HtmlAgilityPack;
using System.Net;
using System.IO;

namespace PhoneFind
{
    class WebRequest
    {
        private String url { get; set; }
        private String searchEngine { get; set; }
        HttpWebRequest HWR_Request = (HttpWebRequest)WebRequest.Create("http://www.hitta.se/ericsson/företag_och_personer");
        public WebRequest(String url, String searchEngine)
        {
            this.url = url;
            this.searchEngine = searchEngine;
        }

        // sends a request to the search engine 
        public String sendRequest(String url, String searchEngine)
        {
            switch (searchEngine){
                case "hitta":
                    //Create a Web-Request to a URL

                    //Send Web-Request and receive a Web-Response
                    HttpWebResponse HWR_Response = (HttpWebResponse)HWR_Request.GetResponse();

                    //Translate data from the Web-Response to a string
                    Stream S_DataStream = HWR_Response.GetResponseStream();
                    StreamReader SR_DataStream = new StreamReader(S_DataStream, Encoding.UTF8);
                    string s_ResponseString = SR_DataStream.ReadToEnd();
                    S_DataStream.Close();
                    break;
            }
            return "";

        }

    }
}
  • 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-14T07:12:15+00:00Added an answer on June 14, 2026 at 7:12 am

    In your form application, your class is named WebRequest, so the compiler is looking for a Create method in that class, rather that System.Net.WebRequest class. In order to resolve this, fully qualify the WebRequest in System.Net:

    HttpWebRequest HWR_Request = (HttpWebRequest)System.Net.WebRequest.Create("http://www.hitta.se/ericsson/företag_och_personer");
    

    Thanks to Amiram for clarifying that it wasn’t an ambiguous name conflict as I originally thought it might be.

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

Sidebar

Related Questions

I developed an benchmark-style console application (C# 4.0). Worked fine with 50,000 or 1,000,000
My application ran fine the first few times and now has decided to stop
I ran python setup.py install in a Windows XP console, and it reported as
I have a console app that's geared to be automatically ran as a Scheduled
I ran the following code, but nothing came up on the console.... #include <stdio.h>
I ran the convert_to_south command on my app. Everything seems to have gone fine:
Just moved to Grails 1.2.1 (used 1.1.1 before). Changed application.properties, ran grails upgrade, fixed
I am developing an Android application, I was doing just fine then I made
I have written a application that parses the html code of some web pages.
I somehow ran into the issue when I was working on an application that

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.