I'm trying to Use URL Routing in ASP.Net for non aspx file extensions
As i started playing around with asp.net my code got messy and was structured in alot of folders To hide my Directory paths and get meaningful comprimated URLS i used URL Routing There are several Documantation on that, for me the easyest Tutorial was https://web.archive.org/web/20201205221404/https://www.4guysfromrolla.com/articles/051309-1.aspx
On default the URL paths show my complete folder structure, to hide this information i use URL Routing After the following code, i was allowed to use redirect with the virtual paths
RouteTable.Routes.Add("login", new Route("login", new RouteHandler(string.Format("~/…/Login.aspx"))));
If you use non .aspx file extensions like HTML you need to add Buildproviders in web.config for that extension
Example:
RouteTable.Routes.Add("testhtml", new Route("testhtml", new RouteHandler(string.Format("~/.../test.html"))));
Web.Config:
<system.web>
<compilation debug="true" targetFramework="4.6.1" >
<buildProviders >
<add extension=".html" type="System.Web.Compilation.PageBuildProvider"/>
</buildProviders>
</compilation>
<…>
Now http://localhost:58119/testhtml is the same as http://localhost:58119/.../test.html with complete path
To my Question
On default ASP.net can ridirect to ~/…/test.pdf or ~/…/test.png.
with URL Routing it again asks for buildproviders for the file extension.
But there are no default buildproviders for these extensions in the msdn documentation if i'm correct :/