Reputation: 1567
I have a funny problem which I cannot explain. I have an ASP.NET-MVC application for sole reason to have a single hhtp endpoint to post some stuff on the server. All other stuff is pure static content.
My structure simplified:
Root/
index.htm
img/
image.png
test.html
In the root I have my index.html whis is served fine. If I point to www.mysite.com/img/image.png the image is shown as it should be. If I point to www.mysite.com/img/test.html I get 500 error. Why is the html not served from subfolder but image is?
EDIT - UPDATE
Url www.mysite.com displays index.html. Url www.mysite.com/index.html results in 500 error.
I cannot explain this to my self. Does ASP.NET MVC application not serves html files and that www.mysite.com hit index.html because (I guess) this is setup as default in IIS settings?
On this observation the question could be rephrased as: Why is img/image-png served but img/test.html not ?
EDIT UPDATE 2
By popular request I post my 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 that single action that return action with JSON rezult, everything elese is simple static web site with static content.
And my controller:
public class ApiController : Controller
{
[HttpPost]
public JsonResult PostSomeData(SomeData someData)
{
// save to database
return Json(true);
}
}
Upvotes: 0
Views: 1527
Reputation: 2541
Whithout posting the code you are using to render your views from your controller , it's hard to tell what's exactly is the issue. But i am guessing it's a routing problem or not calling the html file correctly.
In order to serve your other test.html
you can try this:
public ActionResult Index()
{
var staticPageToRender = new FilePathResult("~/img/test.html", "text/html");
return staticPageToRender;
}
Upvotes: 1