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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:04:24+00:00 2026-06-05T12:04:24+00:00

Do i have to write the attribute [WebGet] above every operation to get access

  • 0

Do i have to write the attribute [WebGet] above every operation to get access via “GET”?
I want that my default ACCESS METHOD will be “GET” not “POST”. Is there a way to do it on web.config/app.config?

  • 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-05T12:04:25+00:00Added an answer on June 5, 2026 at 12:04 pm

    There’s no way to do it only in the configuration. You’ll need to create a new behavior, derived from WebHttpBehavior, and change the default (add a [WebGet] if nothing is there) – see code below. Then, if you want, you can define a behavior configuration extension to use that behavior via config.

    public class StackOverflow_10970052
    {
        [ServiceContract]
        public class Service
        {
            [OperationContract]
            public int Add(int x, int y)
            {
                return x + y;
            }
            [OperationContract]
            public int Subtract(int x, int y)
            {
                return x + y;
            }
            [OperationContract, WebInvoke]
            public string Echo(string input)
            {
                return input;
            }
        }
        public class MyGetDefaultWebHttpBehavior : WebHttpBehavior
        {
            public override void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
            {
                foreach (var operation in endpoint.Contract.Operations)
                {
                    if (operation.Behaviors.Find<WebGetAttribute>() == null && operation.Behaviors.Find<WebInvokeAttribute>() == null)
                    {
                        operation.Behaviors.Add(new WebGetAttribute());
                    }
                }
    
                base.ApplyDispatchBehavior(endpoint, endpointDispatcher);
            }
        }
        public static void Test()
        {
            string baseAddress = "http://" + Environment.MachineName + ":8000/Service";
            ServiceHost host = new ServiceHost(typeof(Service), new Uri(baseAddress));
            host.AddServiceEndpoint(typeof(Service), new WebHttpBinding(), "").Behaviors.Add(new MyGetDefaultWebHttpBehavior());
            host.Open();
            Console.WriteLine("Host opened");
    
            WebClient c = new WebClient();
            Console.WriteLine(c.DownloadString(baseAddress + "/Add?x=6&y=8"));
    
            c = new WebClient();
            Console.WriteLine(c.DownloadString(baseAddress + "/Subtract?x=6&y=8"));
    
            c = new WebClient();
            c.Headers[HttpRequestHeader.ContentType] = "application/json";
            Console.WriteLine(c.UploadString(baseAddress + "/Echo", "\"hello world\""));
    
            Console.Write("Press ENTER to close the host");
            Console.ReadLine();
            host.Close();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a simple web app in PHP that needs to have write access
I have a custom attribute that I want to apply to each methods in
I have to write an XPath expression to get the href attribute of the
I have to write an Nant script that will accept 2 parameters on the
I am trying to check if I have write access to a specific key
I have to write a SNMP module which monitor a certain server application that
hi I have to write a windows api code that encrypts a file by
I want to create a default value for an attribute by defining it in
I have to write a testing module and have c++-Background. That said, I am
I like Python, but I don't want to write 10 lines just to get

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.