Reputation: 1190
I have a simple ASP MVC project. Under this site I need to show plain .html files, without treating routes as controller/action.
I have folder documentation with file index.html in it. I need to have this accessible under www.mydomain.com/documentation, it returns 403. Currently it works only under www.mydomain.com/documentation/index.html
I have added
routes.Ignore("developers/");
into RouteConfig.cs
and in Startup.cs
for OwinAppBuilder
app.UseStaticFiles();
What should I do to have it accessible under www.mydomain.com/documentation/index.html ?
Upvotes: 2
Views: 3260
Reputation: 599
In your route config add
routes.RouteExistingFiles = true;
routes.MapRoute(
name: "staticFileRoute",
url: "Public/{*file}",
defaults: new { controller = "Home", action = "HandleStatic" }
);
In you web.config under <system.webServer>/<handlers>
add
<add name="MyCustomUrlHandler2" path="Public/*" verb="GET" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
Taken from this site if you want to read more about it.
Edit: note that the url in the MapRoute
has the directory Public
in the url, as well as in the path
for the web.config line. If your html file is not in a directory named Public
you will need to change that part to match your directory structure.
Upvotes: 1