I've a ASP.NET MVC 4 Project and I have a subdirectory "test" in the root dir and it contains a index.html
I want wenn the clean URL is called that the index.html is returned
when I call
that I get the Content returned from my "test\index.html"
I've a ASP.NET MVC 4 Project and I have a subdirectory "test" in the root dir and it contains a index.html
I want wenn the clean URL is called that the index.html is returned
when I call
that I get the Content returned from my "test\index.html"
 
    
    The RouteConfig class in the App_Start sub-directory should be adjusted so that the default Controller is Test.  Place your 'test' directory within the Views directory and, if you haven't already, create a TestController.  RouteConfig should look like this: 
public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Test", action = "Index", id = UrlParameter.Optional }
        );
    }
}
 
    
    The easiest way is to put your "test/index.html" as default document in IIS.
If you really want to do it programmatically you'll have to create an action to handle your request and map your default route to it.
Route:
routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "StaticFile", action = "Index", id = UrlParameter.Optional }
        );
Controller/Action:
public class StaticFileController : Controller
{
    // GET: StaticFile
    [AllowAnonymous]
    public FileContentResult Index()
    {
        string imageFile = System.Web.HttpContext.Current.Server.MapPath("~/Test/Index.html");
        byte[] bytes = System.IO.File.ReadAllBytes(imageFile);
        return File(bytes, "text/html");
    }
}
