ASP.NET-MVC How to serve static content? -


i want have static website, made , asp.net-mvc application serve simple http post request save in database. in future perhaps there view implemented not @ moment. found weird behavior cannot explain why?

site structure is:

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

the server iis 8.9 hosted.

my route config , controller are:

public static void registerroutes(routecollection routes) {         routes.ignoreroute("{resource}.axd/{*pathinfo}");          routes.maproute(              name: "apipostdata",              url: "api/{action}",              defaults: new { controller = "api" }         ); }  public class apicontroller : controller {      [httppost]     public jsonresult postsomedata(somedata somedata)     {             // save database             return json(true);     } } 

but behaves wrong , unpredictable: in examples:

www.mysite.com -> displays index.html ok

www.mysite.com/index.html -> error 500

www.mysite.com/img/image.png -> image shwon ok

www.mysite.com/img/test.html -> error 500

www.mysite.com/api/postsomedata -> invokes controller method should

this illogical. why server makes distinction between static context. need explanation of behavior , way force iis serve static content.


Comments