i able to call Get Method.
but fail to call PUT, DELETE Method.
i added in webconfig.
below is my controller code :
when call : this is the error show :
http://localhost:44322/api/PutEmployeeGenderEmpCode/502
<error>
<message>
The requested resource does not support http method 'GET'.
Thanks in advance..
but fail to call PUT, DELETE Method.
i added in webconfig.
<system.webServer><handlers><remove name="BlockViewHandler"/><add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" /><remove name="ExtensionlessUrlHandler-Integrated-4.0"/><remove name="OPTIONSVerbHandler"/><remove name="TRACEVerbHandler"/><add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0"/></handlers></system.webServer>
below is my controller code :
[HttpPut] [Route("api/PutEmployeeGenderEmpCode/{_EmpCode}")] public void PutEmployeeGenderEmpCode(string _EmpCode) { string TempValue = "1"; SqlConnection Conn = new SqlConnection(ConnectionString); CheckConnectionStatus(Conn); Conn.Open(); string SQLCommand = "UPDATE [dbo].[M_EMP_MASTER] "; SQLCommand = SQLCommand + "SET "; SQLCommand = SQLCommand + "[EMP_GENDER] = '" + TempValue + "' "; SQLCommand = SQLCommand + "WHERE [EMP_CODE] = '" + _EmpCode + "'"; var cmd2 = new SqlCommand(SQLCommand, Conn); cmd2.ExecuteNonQuery(); Conn.Close(); Conn.Dispose(); }
when call : this is the error show :
http://localhost:44322/api/PutEmployeeGenderEmpCode/502
General ---------- request URL: https://localhost:44322/api/PutEmployeeGenderEmpCode/502 Request Method: GET Status Code: 405 Remote Address: [::1]:44322 Referrer Policy: no-referrer-when-downgrade Response Header ---------------- allow: PUT cache-control: no-cache content-length: 92 content-type: application/xml; charset=utf-8 date: Mon, 18 May 2020 08:39:04 GMT expires: -1 pragma: no-cache server: Microsoft-IIS/10.0 status: 405 x-aspnet-version: 4.0.30319 x-powered-by: ASP.NET x-sourcefiles: =?UTF-8?B?QzpcMjAyMFxDQlMyMDAwNCAtIE1PQklMRSAtIFRFU1RcV2ViQVBJXzNcV2ViQVBJM1xXZWJBUEkzXGFwaVxQdXRFbXBsb3llZUdlbmRlckVtcENvZGVcNTAy?= Request Header --------------- :authority: localhost:44322 :method: GET :path: /api/PutEmployeeGenderEmpCode/502 :scheme: https accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9 accept-encoding: gzip, deflate, br accept-language: en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7 cookie: ai_user=nrUCU|2020-04-23T13:17:35.464Z sec-fetch-dest: document sec-fetch-mode: navigate sec-fetch-site: none sec-fetch-user: ?1 upgrade-insecure-requests: 1 user-agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Mobile Safari/537.36
<error>
<message>
The requested resource does not support http method 'GET'.
Thanks in advance..