Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is what I have done before:</p> <pre><code>public class MvcApplication : HttpApplication { public static void RegisterGlobalFilters(GlobalFilterCollection filters) { filters.Add(new HandleErrorAttribute()); } public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); MapRoute(routes, "", "Home", "Index"); /* other routes */ MapRoute(routes, "{*url}", "Documentation", "Render"); } } </code></pre> <p>Now any routes that are not matched are passed to the <code>DocumentationController</code>. My documentation controller looks as follows:</p> <pre><code>public class DocumentationController : Controller { public ActionResult Render(string url) { var md = new MarkdownSharp.Markdown(); // The path is relative to the root of the application, but it can be anything // stored on a different drive. string path = Path.Combine(Request.MapPath("~/"), GetAppRelativePath().Replace('/', '\\')) + ".md"; if (System.IO.File.Exists(path)) { string html = md.Transform(System.IO.File.ReadAllText(path)); return View("Render", (object)html); } // return the not found view if the file doesn't exist return View("NotFound"); } private string GetAppRelativePath() { return HttpContext.Request.AppRelativeCurrentExecutionFilePath.Replace("~/", ""); } } </code></pre> <p>All this does is to find markdown files and render them accordingly. To update this for your case, you may want to do the following:</p> <pre><code> routes.MapRoute( "Parameter1", "{controller}/{action}/{lang}/{*url}", new { controller = "Manuals", action = "Download", lang = "en-US", prod = "sample" } ); </code></pre> <p>Make sure it is after the <code>{controller}/{action}/{lang}/{prod}</code> route. This should cause a URL such as <code>/Manuals/Product/en-US/images/image.svg</code> or even <code>images/image.svg</code> (if the browser is in <code>/Manuals/Product/en-US/sample</code> to invoke the the <code>Download</code> action. You can then adapt the code I wrote to map that URI to the physical location. A problem you may run into is that "images" are considered to be product and that <code>/Manuals/Product/en-US/images</code> would think its a product.</p> <p>The Images action can be can look as follows.</p> <pre><code>public ActionResult Download(string url) { /* figure out physical path */ var filename = /* get filename form url */ var fileStream = [...]; Response.Headers.Remove("Content-Disposition"); Response.Headers.Add("Content-Disposition", "inline; filename=" + filename); string contentType = "image/jpg"; return File(fileStream, contentType, filename); } </code></pre> <p>You can get more information of the FileResult at <a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.fileresult.aspx" rel="nofollow">MSDN</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload