本文介绍了如何解决MVC 5更新和删除错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在.net 4.7.2中构建了MVC 5 Web应用程序.它在我的本地计算机上运行良好.更新和删除命令失败,由于这篇文章,我现在对此进行了整理:

更新:

  1. 进一步研究之后,我的托管服务器现在更新为.net 4.8,现在一切都失败了.现在,我什至无法加载索引视图页面.它在与上述相同的40行处中断.
  2. 在IIS中,我的应用程序池设置为集成的.net 4.0.从下拉列表中看不到更高的内容.
  3. 在IIS中,HTTP动词列表中没有过滤任何内容,我认为这意味着它应该接受任何内容.

更新2

  1. 更新到.net 4.8后,我现在遇到一个新错误

我已启用IIS中的所有功能,包括将所有ASP配置从只读"更改为读/写".

我担心我可能会将漏洞引入VPS ...

要使它正常工作,我还需要做其他事情吗?

解决方案

所以,这就是我最终使它起作用的方式:

  1. 我被Plesk托管为控制面板".显然,Plesk有一些锁,我必须在这里解锁:

感谢 https://support.plesk.com/hc/en-us/articles/115000287305-Site-shows-500-19-Internal-Server-Error-Config-Error-Lock-violation.我很惊讶我的房东对此无能为力!

  1. 在启用VPS中其他所有功能的过程中,我最终启用/安装了WebDAV.显然,这也不会允许"编辑/删除操作.我没有卸载它,而是从web.config整理出了这样的代码:

    < system.webserver>...

感谢 Web API放置请求生成Http 405不允许的方法错误

I have built MVC 5 Web application in .net 4.7.2. It runs fine in my local machine. Update and Delete commands were failing, which I have now sorted out thanks to this post: DELETE/PUT verbs result in 404 Not Found in WebAPI, only when running locally, I added this line to the web.config and all the CRUD now works:

<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0

However, when I publish the application to my hosting server it breaks at this line in the web.config.When I remove the line only Create and Retrieve data works, but Update and Delete fails with the error:

I understand this is because the model is null/nothing at this point.

This is my delete function showing where the error starts...

    Public Function Delete(ByVal id As Integer) As ActionResult

        Dim Client As HttpClient = New HttpClient()
        Client.BaseAddress = New Uri(myWeb & "AppMenuCRUD")

        Dim APIConsumer = Client.DeleteAsync("AppMenuCRUD/" & id.ToString())
        APIConsumer.Wait()

        Dim Result = APIConsumer.Result << failure here: Error 404

        If Result.IsSuccessStatusCode Then
            Return RedirectToAction("Index")
        End If

        Return View("Index")

    End Function

The hosted server is running Windows Server 2016, .Net 4.7.2. I have enabled read/write to the website folder.

This is my IIS Settings in the hosting server:

UPDATES:

  1. Having looked further into this, my hosting server is now updated to .net 4.8 and everything now just fails. I am now not able to even load the index view page. It breaks at the same line 40 as above.
  2. In IIS, my application pool is set to integrated, .net 4.0. I cannot see anything higher from the dropdown list.
  3. In IIS, I have nothing filtered in the list of HTTP Verbs, which I believe means it should accept anything.

UPDATE 2

  1. After the updates to .net 4.8, I am now getting a new error

I have enabled everything in the IIS, including changing all the ASP Configurations from Read Only to Read/Write.

I'm fearing I may introduce vulnerabilities to the VPS...

Is there anything else I need to do to get this to work?

解决方案

So, this is how I finally got it to work:

  1. I am hosted with Plesk as 'control cpanel'. Apparently, Plesk has some lock which I had to unlock here:

Thanks to https://support.plesk.com/hc/en-us/articles/115000287305-Site-shows-500-19-Internal-Server-Error-Config-Error-Lock-violation. I was quite surprised my host could not help with this!

  1. In the gymnastics of enabling everything else in my VPS, I ended up enabling/installing WebDAV. This also apparently does not 'allow' Edit/Delete actions. Instead of uninstalling it, I sorted it out from the web.config like this:

    <system.webserver>...

Thanks to Web API Put Request generates an Http 405 Method Not Allowed error

这篇关于如何解决MVC 5更新和删除错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 22:18
查看更多