0
votes

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:

Object reference not set to an instance of an object.

at this line in the Index view: Line 40: @For Each item In Model

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:

enter image description here

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

Lock Violation

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?

2

2 Answers

0
votes

Sometimes you need to update manually the Web.config when you change the target framework, please double check those lines:

<system.web>
    <compilation debug="true" targetFramework="4.8">
    <httpRuntime targetFramework="4.8" />
...
0
votes

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:

Plesk > Tools & Settings > Security > Prohibit the ability to override handlers

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