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 471773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:01:11+00:00 2026-05-13T00:01:11+00:00

I am working on a ASP .NET mVC project & i have to change

  • 0

I am working on a ASP .NET mVC project & i have to change HttpHeaders. see the foolowing code snippet:

WebRequest req= HttpWebRequest.Create("myURL");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

req.Headers.Add("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.15) Gecko/2009101601 Firefox/3.0.15 (.NET CLR 3.5.30729)");
req.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
req.Headers.Add("Accept-Language", "en-us,en;q=0.5");

this gives a exception i.e.

This header must be modified using the appropriate property.\r\nParameter name: name.

Anyone suggets solution for it

  • 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-05-13T00:01:11+00:00Added an answer on May 13, 2026 at 12:01 am

    In addition to what @Mehrdad Afshari says, your req variable needs to be of type HttpWebRequest. WebRequest (the abstract parent class) doesn’t have the UserAgent and Accept properties.

    HttpWebRequest req = WebRequest.Create( "http://..." ) as HttpWebRequest;
    

    Also, I just want to make sure that you are really trying to change the headers on a request that you are sending from your MVC application, not on the response that is being sent back from your MVC application. The way you’ve written the code is a little confusing as you are setting the headers after receiving the response, which won’t work, and because you specifically refer to MVC. If you are creating a WebRequest on the server it really doesn’t matter whether you are using WebForms or MVC, the process is still the same.

    If it turns out that you are trying to change the format of the response you are sending back, leave a comment and let me know.

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

Sidebar

Related Questions

background:Me and my coworkers are working on asp.net mvc project ... we have a
I'm working in an ASP.NET MVC project where I have created a two LinqToSQL
I'm working on an asp.net-mvc project. I have an Items table and a Tags
I am working on asp.net MVC 3 project. I am using EF 4.1 code
I am currently working on a ASP.NET MVC 3 project in which I have
I am working on an ASP.NET MVC Project and I have a number of
I have been working on a ASP.NET MVC 2 project and i've been thinking
I'm working on an ASP.Net MVC project and have been learning a few little
I have set up an ASP.NET MVC project, and everything is working great, but
So, I'm working on a new project using ASP.NET MVC. Honestly I don't have

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.