. NET Core web API didn't working on hosted server,but its running smoothly on my development system RRS feed

  • Question

  • User-623162908 posted

    here is the response from the server  web

    visual studio 2019 & window server 2012 r2 & .net core 2.2

    sent request url "../../api/values" with ajax, expect return "hello world"

    but it is ok when I request static file like 'welcome.html'.

    now the error scenario is any api request response 404

    so, do you guys have any advice? thanks ahead

    • New Progress at Sep 25,2019

    one gentle man tell me, I couldn't treat .net core as .net framework I should publish the website via visual studio instead of copy the file to server.

    I did it as he say, The original 404 error disappeared.

    I encounter another error , but whatever, the new 404 error appear.

    another error image display

    enter image description here

    it seems my api still didn't work.

    Wednesday, September 25, 2019 3:51 AM

All replies

  • User-782232518 posted

    You didn't publish the .NET Core app yet, so that IIS doesn't even use ASP.NET Core module to execute the right bits. That's why the 404 comes from Static File handler.


    Wednesday, September 25, 2019 4:43 AM
  • User-623162908 posted

    Thank you for your answer, 

    Is this  the .net core webapi's features? I mean I have no choice but the way to publish the web ,

    because I didn't use the publish when I develop on the .net framework(I just copy the file to server, and it is run well)

    Wednesday, September 25, 2019 5:20 AM
  • User-623162908 posted

    Hi @lextm 

    Summary of the problem I am having:

    I just publish my web to server, and copy the static folder (e.g. css, script, view) to my server

    I still get the 404 error,

    but the error detail is changed

    Error I am receiving:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
    <title>404 - File or directory not found.</title>
    <style type="text/css">
    body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
    fieldset{padding:0 15px 10px 15px;}
    h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
    #header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
    #content{margin:0 0 0 2%;;}
    <div id="header"><h1>Server Error</h1></div>
    <div id="content">
    <div class="content-container"><fieldset>
    <h2>404 - File or directory not found.</h2>
    <h3>The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.</h3>

    It seems my api isn't work.

    Wednesday, September 25, 2019 6:22 AM