I am getting 405 error
i have attached the screenshot and code for review.
getDetails(rolename: Role): Observable<Role> {
let value = Array();
let headers = new Headers();
headers.append('Content-Type', 'application/json');
let options = new RequestOptions({ headers: headers });
var passData = {
"Abc": "khkh",
"cde": "hkhk",
"fgh": "hkhk",
"ijk": "acc"
};
let body = this.serializeObj(passData);
return this.http.post("http://localhost/service.svc/GetResults",
body,
options).pipe(
map((response: Response) => {
debugger;
return <Response>response;
})).catch(this.handleErrorObservable);
}
i have added cors in webconfig
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="Content-Type" />
<add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE,OPTIONS" />
</customHeaders>
</httpProtocol>
my Post method is pointing to WCF Rest
[OperationContract]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json,
RequestFormat =WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "GetResults")]
List<ResponceModel> GetResults(Model request);
I cant able to post . please help me.
I got the Answer
I hosted the application in same server and tried to run in the same appdomain . so there was no cross domain issue occured. thus my issue solved. Thanks for the help guys