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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:51:05+00:00 2026-06-07T08:51:05+00:00

I have an OperationContract method where I am trying to query and insert data

  • 0

I have an OperationContract method where I am trying to query and insert data into the database. I am using a POST method and calling the service from javascript in the browser. The WCF Service is in the same domain, so I should not have to use JSONP. I am also modifying data so it should be a POST request not a GET request. However I am still getting a “Method not allowed error”. Has anyone encountered this situation?

My service is being called at

http://some_url.com/services/ProfileService.svc/json/CurrentUser

Strangely, it seems to be called via a GET request when I go this url even though I specifiy a POST. On the page load, however, it seems to be attempting a POST request.

Browser response when going to the url:

Request URL:http://some_url.com/services/ProfileService.svc/json/CurrentUser
Request Method:GET
Status Code:405 Method Not Allowed
Request Headersview parsed
GET /services/ProfileService.svc/json/CurrentUser HTTP/1.1

Here is my method that I am trying to call:

[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json)]

public HIPUser GetCurrentUser()
{
    string[] domainUser;
    string Auth_User = HttpContext.Current.User.Identity.Name.ToString().ToLower();
    domainUser = Auth_User.Split('\\');
    string user = domainUser[1];
    Debug.WriteLine(user);

    ProfileManager pm = new ProfileManager();
    var results = pm.GetUserByUserName(user);

    if (results.Length > 0)
    {
        return results.First();
    }
    else
    {
        Debug.WriteLine("IS NULL");
        var x = pm.CreateUser(user, null, null);
        Debug.WriteLine(x.UserName);
        return x;
    }
}

Client:

function getCurrentUser() {

$.ajax({
    type: "POST",
    url: "services/ProfileService.svc/json/GetCurrentUser",
    contentType: "application/json; charset=utf-8",
    data: null,
    dataType: "json",
    error: function (request, error, u) {
        alert('blargherror: ' + error);
    },
    success: function (result, status) {
        alert(result.d);
    }
});
}

Not sure if needed but Web.Config:

<behaviors>
   <endpointBehaviors>
        <behavior name="jsonBehavior">
            <enableWebScript />
        </behavior>
    </endpointBehaviors>

    <serviceBehaviors>
        <behavior name="metaBehavior">
            <serviceDebug includeExceptionDetailInFaults="true" />
            <serviceMetadata httpGetEnabled="true" />
        </behavior>
    </serviceBehaviors>
</behaviors>

<serviceHostingEnvironment 
    aspNetCompatibilityEnabled="true"
    multipleSiteBindingsEnabled="true" />

<services>
    <service name="ProfileService" behaviorConfiguration="metaBehavior">
        <endpoint address="/json" 
            behaviorConfiguration="jsonBehavior"
            binding="webHttpBinding" 
            bindingConfiguration="secure" 
            contract="ProfileService" />
        <endpoint address="" 
            binding="basicHttpBinding" 
            bindingConfiguration="secure" 
            contract="ProfileService" />
    </service>
</services>

Edit to Web.Config – Adding bindings

<bindings>
        <webHttpBinding>
            <binding name="secure">
                <security mode="TransportCredentialOnly">
                    <transport clientCredentialType="Windows"/>
                </security>
            </binding>
        </webHttpBinding>
        <basicHttpBinding>
            <binding name="secure">
                <security mode="TransportCredentialOnly">
                    <transport clientCredentialType="Windows" />
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
  • 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-07T08:51:08+00:00Added an answer on June 7, 2026 at 8:51 am

    I was able to figure this out. There was an issue with the return object being an unknown type, so it wasn’t able to be serialized into a JSON object. Wasn’t sure how to serialize the object to get it to work with my method, so I ended up just changing the method to return a string constructing my own custom JSON string, and using the eval() function to turn it into a JSON object.

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

Sidebar

Related Questions

I have a wcf service defined like this: [OperationContract] [WebInvoke(Method = POST, ResponseFormat =
I'm trying to send data from a client application using jQuery to a REST
I have written some data fetch service which fetches some entities from main web
I'm trying to setup a WCF web service to be consumed by JavaScript using
I have the following .NET web service with the following signature (IServices.cs): [OperationContract] [WebInvoke(Method
I have a simple WCF service method: [OperationContract] public SetupGameResult SetupGame(long player1Id, long player2Id,
Hi I have next WCF service. [OperationContract] [WebInvoke(Method = GET, BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat
I have created the simple web service. Code: [ServiceContract] public interface ITsdxService { [OperationContract]
I am trying to use a web service built on asp.net wcf from iPhone
I have a WCF restful service that I'm trying to upload an image to.

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.