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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:31:24+00:00 2026-06-03T04:31:24+00:00

I have a c# web service with the following definition: [WebInvoke(Method = POST, ResponseFormat

  • 0

I have a c# web service with the following definition:

    [WebInvoke(Method = "POST",
        ResponseFormat = WebMessageFormat.Json,
        RequestFormat = WebMessageFormat.Json,
        BodyStyle = WebMessageBodyStyle.Wrapped,
        UriTemplate = "BCryptLogin")]
    LoginResponse BCryptLogin(LoginData logindata);

And the actual function is

    public LoginResponse BCryptLogin(LoginData logindata)
    {
        string login = logindata.login;
        string password = logindata.password;

        // code be here
    }

When trying to access the “logindata.login” I get a NullReferenceException:

System.NullReferenceException was unhandled by user code
Message=Object reference not set to an instance of an object.
Source=LoginService
StackTrace:
   at LoginService.LoginService.BCryptLogin(LoginData logindata) in C:\services\LoginService\LoginService\LoginService.svc.cs:line 74
   at SyncInvokeBCryptLogin(Object , Object[] , Object[] )
   at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)

This is my first attempt at POST web service and I am fairly clueless :S What is going wrong?

My testing request looks like this:

{"login":"username","password":"password"}

(also tried)

{"LoginData":{"login":"username","password":"password"}}

And the LoginData object is defined like this:

[DataContract]
public class LoginData
{
    [DataMember]
    public string login { get; set; }
    [DataMember]
    public string password { get; set; }
}
  • 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-03T04:31:26+00:00Added an answer on June 3, 2026 at 4:31 am

    Your function is expecting an object, but your passing two values.

    {"login":"username","password":"password"}
    

    You need to create an object in JavaScript and pass it to your function.

    var LoginData = {};
    LoginData.login = "username";
    LoginData.password = "password";
    

    Then pass this object to your method in your JSON request, using the following syntax.

    var jsonRequest = {logindata: LoginData};
    

    NOTE: The parameter name on your method “logindata” must be the same in your JSON call, it’s case sensitive.

    I suggest you use JSON.org lib to convert your object into a valid JSON request.

    JSON.stringify(jsonRequest);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following JSON coming back from a web service which I am
When I call, the service's method, I have Web Service Exception happening which I
I have a web service method where I would like to throw some custom
I have a web service that returns following type: <xsd:complexType name=TaggerResponse> <xsd:sequence> <xsd:element name=msg
Suppose I have an asmx web service at the following address: http://localhost/BudgetWeb/Service.asmx This web
I have a web service that has an input object similar to the following.
I have the following web service: [ScriptService] public class Handler : WebService { [WebMethod]
I have the following web service that allows me uploading files: [WebService(Namespace = http://tempuri.org/)]
I have created a web service for the following code but I am getting
I have a web-service running on Windows Azure which returns JSON that I consume

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.