0
我使用微软ASP.NET MVC AngularJs时,我可以从数据库中获取记录,并插入新的项目数据库,但是当我更新项目,收到错误找不到404角与MVC告诉我的错误未找到404
这里是我的代码
C#代码:
[HttpPut]
public void UpdateContinent(Continent Con)
{
MyDatabaseEntities db = new MyDatabaseEntities();
Continent conti = db.Continents.Find(Con.ContinentId);
conti.ContinentName = conti.ContinentName;
db.SaveChanges();
}
角:
app.controller("myCntrl", function ($scope, $http) {
$scope.Continent = {
ContinentId: '',
ContinentName: ''
};
$scope.Update = function (con) {
$scope.Continent = con;
$http.post('/Home/UpdateContinent', { Con: $scope.Continent })
.success(function (data) {
$('#DivForEdit').modal('hide');
$scope.clear();
$scope.GetAll();
})
.error(function (msg) {
alert(msg)
})
}
我曾尝试这个代码的web.config文件中:
<system.webServer>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0"
path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE"
type="System.Web.Handlers.TransferRequestHandler"
resourceType="Unspecified" requireAccess="Script"
preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
它没有工作,然后我换成这个代码,并没有太多的工作:
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<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>
请帮助我。我在角新.....提前
感谢
哪里是'$ scope.GetAll()'实现的吗? – kubuntu
执行了“/ Home/UpdateContinent”路由处理程序吗? – hamou92
您正在使用[HttpPut]在服务和发布角度,更改为张贴或投入 –