简体   繁体   中英

ASP.NET Web API - Changes to Controller file not being picked up

I'm new to using Web API but was following the tutorial at http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api

In my own scenario I want the user to pass an XML file and for this XML file to be saved in a specific directory.

While testing this on our Amazon web server the user was getting the response "The remote server returned an error: (500) Internal Server Error."

When I looked at the window application error logs I could see that the path I stipulated for saving the XML file was incorrect however when I corrected this and tried again the same error appeared and the error log still showed the previous path.

I've found that even if I delete the Controller.cs file the same error appears in the log file.

I'm sure I'm making some sort of newbie error but can't see it.

Do the actions in the controller files get cached and if so how do you clear the cache or disable it?

Thanks in advance and below is the code in the controller

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Xml.Linq;

namespace API.Controllers
{
    public class MyController : ApiController
{
    [Route("api/mywebsite/sendXML")]        
    public async void ReceiveXml()
    {
        var doc = XDocument.Load(await Request.Content.ReadAsStreamAsync());
        var saveLoc = @"C:\inetpub\wwwroot\API\Requests\Test.xml";
        doc.Save(saveLoc);
    }
}

}

The .cs files get compiled into a .dll, which contains all the actual code that the .Net runtime executes. If you make changes to your code, you need to recompile the code, and deploy your dll file to the web server.

You have to compile the code before any changes are made. Recompile and Redeploy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM