Cannot get data after login ASP.net session key method

The site I’m building is done using AngularJS front-end and Windows webforms in the back-end. I believe the Authorization done through ASP.net Session Key.

So you create a AngularJS Post method to “login” and then you execute another method to “getuserdata”.

Login:

{ "method": "logintheconsumer",
"email":MyEmail,
"password":MyPassword}

Get User Details:

{ "method": "getconsumerdetails" }

This works correctly using POSTMAN API App, but when I implement the code in JavaScript/AngularJS, it throws error response.

I have not implemented any other code structure. What Am I missing … ?

Answer

That could be an issue of server side. You need to make sure CORS in Webconfig is allowed to access their Service. This may work.

<httpProtocol>
            <customHeaders>
                <add name="Access-Control-Allow-Origin" value="*" />
                <add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept, Cache-Control" />
                <add name="Access-Control-Allow-Methods" value="GET,PUT,POST,OPTIONS" />
            </customHeaders>
        </httpProtocol>