Why does ASP.NET-MVC does not serve static html from subfolder? -


i have funny problem cannot explain. have asp.net-mvc application sole reason have single hhtp endpoint post stuff on server. other stuff pure static content.

my structure simplified:

root/     index.htm     img/         image.png         test.html 

in root have index.html whis served fine. if point www.mysite.com/img/image.png image shown should be. if point www.mysite.com/img/test.html 500 error. why html not served subfolder image is?

edit - update

url www.mysite.com displays index.html. url www.mysite.com/index.html results in 500 error.

i cannot explain self. asp.net mvc application not serves html files , www.mysite.com hit index.html because (i guess) setup default in iis settings?

on observation question rephrased as: why img/image-png served img/test.html not ?

edit update 2

by popular request post route config:

public static void registerroutes(routecollection routes) {         routes.ignoreroute("{resource}.axd/{*pathinfo}");          routes.maproute(              name: "apipostdata",              url: "api/{action}",              defaults: new { controller = "api" }         ); } 

besides single action return action json rezult, elese simple static web site static content.

and controller:

public class apicontroller : controller {      [httppost]     public jsonresult postsomedata(somedata somedata)     {             // save database             return json(true);     } } 

whithout posting code using render views controller , it's hard tell what's issue. guessing it's routing problem or not calling html file correctly.

in order serve other test.html can try this:

public actionresult index() {      var staticpagetorender = new filepathresult("~/img/test.html", "text/html");     return staticpagetorender; } 

Comments