2016-09-11 19 views
0

我对我的$ http.POST()使用Angular 1.5,并且一切正常,但我不断收到此错误:如何允许本地主机和远程IIS 8.x或更高的POST,PUT

**GENERAL** 
Request URL:http://localhost/ThingBlu/OmniGrow/js/json/logged-users.json 
Request Method:POST 
Status Code:405 Method Not Allowed 
Remote Address:[::1]:80 

**Response Headers** 
Allow:GET, HEAD, OPTIONS, TRACE 
Cache-Control:private 
Content-Length:5448 
Content-Type:text/html; charset=utf-8 
Date:Sun, 11 Sep 2016 18:08:27 GMT 
Server:Microsoft-IIS/10.0 
X-Powered-By:ASP.NET 

**Request Headers** 
Accept:application/json, text/plain, */* 
Accept-Encoding:gzip, deflate 
Accept-Language:en-US,en;q=0.8 
Authorization:Basic OWFjMTIwMTAtNjhmZC00YTY4LWIxMTQtMTI3NjcyYmRkMmNkOjRmOGJkMDg0LTY2NDQtNDVmMi1iNGI4LWI4OTgwNzgyMDkzZA== 
Connection:keep-alive 
Content-Length:305 
Content-Type:application/json;charset=UTF-8 
Cookie:XDEBUG_SESSION=XDEBUG_ECLIPSE; ASPSESSIONIDQARBBSBC=LGJPEMMBPPMIKGAEMPOKDDKP; ASPSESSIONIDQAQBBRDC=HNLHMCECDLFMFBMOFMNFNNEA; ASPSESSIONIDSARCBSBD=DMGPJIECDOKINIEIIADELBOG; ASPSESSIONIDSCQBCQCD=HHHNEBHCACCJABGNFAMFHNAD; ASPSESSIONIDQATBARBD=KFNLJLHCMOECJOMCDDOFBINL; ASPSESSIONIDQCSABTAC=GDGJMOMCNPDBJAAOKJJHDDGH 
DNT:1 
Host:localhost 
Origin:http://localhost 
Referer:http://localhost/ThingBlu/OmniGrow/index.html 
User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.101 Safari/537.36 

这里的问题:

我的WebConfig文件有以下几点:

<modules> 
    <remove name="WebDAVModule" /> 
</modules> 
<handlers> 
    <remove name="WebDAV" /> 
</handlers> 

发生了什么事是每当我逐句通过代码,以下,并触及特定部分,会出现上述错误。

我正在写一个本地JSON文件,这是我在Frontier Communications工作时成功完成的。这对于大多数职位感到懊恼的说非常可能是非常可能的。我已经做到了,FRONTIER和T-MOBILE也是如此。这就是说,这是我的角码:

  /** 
      * Then log the person in 
      * @returns {object through promises} 
      */ 
      ctrlLogin.fetchLogin = function() { 

       //SUBMIT FORM 
       $scope.submit = function() { 
        console.log('Submit Clicked'); 
        //Encode Password if FormData is VALID 
        if ($scope.formData) { 
         formObj = { 
          uid: $scope.formData.myusername, 
          pwd: $scope.encode64($scope.formData.mypassword), 
          rmbr: $scope.formData.rememberme 
         }; 
         //Login Data 
         loginData.svc.getLoginData(formObj).then(function (result) { 
          console.log("Login message: ", result); 
          //if success send the person through 
          if (result.data.message === "failure") { 
           console.log("ERROR: ", result.data.message); 
           $scope.changeRoute("/error"); 
          } else { 
           console.log("SUCCESS: ", result.data); 

           //Get Path to JSON 
           $http.get(SVCURLS.data.loggedusers).then(function (data) { 
            //SUCCESS so therefore pass ACTIVE = 1 for DASHBOARD as that's 
            //where we're going next. 
            if (appservice.appFuncs.saveToJson(result.data, 1)) { 

             data.users = angular.toJson(result.data); 
             //use $.param JQUERY function to serialize the data from JSON 
             $scope.users = $.param(data.users); 
             //CONFIG using HEADERS 
             var config = HEADERS.tokenheaders; 
             **//NOTE: THIS IS THE POINT AT WHICH THE 405 ERROR OCCURS** 
             $http.post(SVCURLS.data.loggedusers, data.users, status, config) 
               .success(function (data, status, headers, config) { 
                //SUCCESS CALBACK 
                $scope.PostDataResponse = data; 
                console.log("SUCCESS Writing to JSON FILE!"); 
                window.location.href = "main-page.html"; 
               }) 
               .error(function (data, status, headers, config) { 
                //FAILURE CALLBACK 
                $scope.PostDataResponse = "DATA: " + data + 
                  "<hr/>Status: " + status + 
                  "<hr/>Headers: " + headers + 
                  "<hr/>Config: " + config; 
                console.log("ERROR Writing to JSON FILE"); 
                return deferred.reject(data ? data : '[NO DATA]'); 
               }); 
            } else { 
             //ERROR show what happened 
             console.log("ERROR: ", data); 
             //Now flip the pages that the session has been 
             //Created 
             $scope.msg = "There was an error saving your information."; 
             deferred.reject(data ? data : '[NO DATA]'); 
            } 
           }); 
          } 
         }); 
        } 
        return "intial load"; 
       }; 
      }; 
      ctrlLogin.fetchLogin(); 

帮助将不胜感激。谢谢。

回答

0

它可能是一些其他模块(不是WebDAV)具有冲突的动词过滤器。 您可以尝试查看iis config文件夹中applicationHost.config文件的内容。可疑模块是具有相同路径和类似动词的模块。例如,如果某个模块X在IIS管理控制台中为您的应用程序禁用,但在applicationHost.config中定义了匹配的路径/动词过滤器,则它的处理程序仍将作为请求管道的一部分调用,并且模块将生成405状态。 如果您发现任何冲突的模块,可以将其从管道中移除,类似于您在web.config文件中为WebDAV执行的操作。

相关问题