Message resources does not support HTTP method ":" request "POST configuration solution
Refers to the System. Web. Http; Also added a [HttpPost] but not all,
But to a server in the local test would have test not
The great god, solving
CodePudding user response:
Cross-domain access may encounter problems such as
Some still need to access the OPTIONS to determine whether to support the POST
https://blog.csdn.net/qq_39393671/article/details/80967924
CodePudding user response:
reference 1st floor stherix response: cross-domain access may encounter problems such as Some still need to access the OPTIONS to determine whether to support the POST https://blog.csdn.net/qq_39393671/article/details/80967924 In the Web. Config configuration inside the cross-domain request but still can't CodePudding user response:
The code to see, We first determine whether webapi or MVC, Because the.net MVC created in webapi, Don't need additional reference System. Web. Http, he would help you reference CodePudding user response:
refer to the second floor L736454 response: Quote: refer to 1st floor stherix response: Cross-domain access may encounter problems such as Some still need to access the OPTIONS to determine whether to support the POST https://blog.csdn.net/qq_39393671/article/details/80967924 In the Web. Config configuration inside the cross-domain request but still can't I used API, no this problem with ajax But others write the vue to access must also write a OPTIONS, to return the support list, or a browser error CodePudding user response:
refer to the third floor is nu month god reply: to look at the code, We first determine whether webapi or MVC, Because the.net MVC created in webapi, Don't need additional reference System. Web. Http, he would help you reference Is not the MVC webapi. To see which parts of the code, the controller? CodePudding user response:
Behind you there is no need to return the OPTIONS processing engineering request 200 and head should agree in general is trouble CodePudding user response:
# region POST ///& lt; Summary> ///add menu information ///& lt;/summary> ///& lt; Param name="siteId" & gt; Site ID ///& lt; Param name="img" & gt; The picture & lt;/param> ///& lt; Param name="pageUrl & gt;" Page jump path & lt;/param> ///& lt; Param name="menuName" & gt; The menu name & lt;/param> ///& lt; Param name="showIndex & gt;" Sorting number & lt;/param> ///& lt; Param name="showState & gt;" State & lt;/param> ///& lt; Returns> [HttpPost] Public HttpResponseMessage menus (string siteId, string img, string pageUrl, string menuName, int showIndex, int showState) { //create parameter validation Bool status=true; String errMsg=string. The Empty; if (! ModelState. IsValid) { The status=false; } If (siteId. Length<6) { The status=false; ErrMsg="siteId wrong"; } If (showIndex<0 | | showIndex> 200) { The status=false; ErrMsg="showIndex is not greater than or less than 0 200"; } if(! (showState==0 | | showState==1)) { The status=false; ErrMsg="showState can only enter 0 and 1"; } //business logic If (status) { Try { MenusModel model=new menusModel ();//instantiate the model layer Model. The siteId=siteId; Model. PageUrl=pageUrl; Model. MenuName=menuName; Model. ShowIndex=showIndex; Model. ShowState=showState; Model. The img=img; Int resultCount=new menusDal (.) menusAdd (model); If (resultCount==0) { The status=false; ErrMsg="add failure"; } } Catch Exception (err) { The status=false; ErrMsg=err. ToString (); } } //determine state String resultJson=string. The Empty; If (status) { Success success=new success () { Result="success", }; ResultJson=JsonConvert. SerializeObject (success); } The else { Fail fail=new fail () { Result="fail", ErrMsg=errMsg }; ResultJson=JsonConvert. SerializeObject (fail); } Return new HttpResponseMessage {Content=new StringContent (resultJson, System. Text. Encoding UTF8, "application/json")}; } # endregion debugger; Var formData=https://bbs.csdn.net/topics/new formData (); FormData. Append (" siteId ", "100000"); FormData. Append (" url ", "VSSJDKHSVJV"); FormData. Append (" img ", "1234"); FormData. Append (" showIndex ", 1); FormData. Append (" showState ", 0). FormData. Append (" menuName ", "about us") $. Ajax ({ Url: "https://* * * * * */*/menus', Type: "POST", Data: formData, ContentType: false, ProcessData: false, Success: the function (data) { //upload success console.log(data); }, Error: function (data) { //upload abnormal console.log(data); } }); </script> CodePudding user response:
If you are a webapi to upload pictures, So take a look at this https://blog.csdn.net/hanjun0612/article/details/53518581 CodePudding user response:
refer to the eighth floor is nu month god reply: if you are a webapi to upload pictures, nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull