Search code examples
pythonasp.net.netnginxssi

Have nginx process an aspx file as though it were html


I have nginx running on Linux. I want to take an .aspx webpage and output just the html from it (no <% %> directives, imports or page declarations.)

For simplicity's sake, assume that all .aspx pages I host are simply .html files renamed with a .aspx extension.

When I point nginx to the location of index.aspx, it asks me to download the file instead of displaying the file's html contents, whereas index.html displays fine.

I have thought of a few ways I could solve this problem.

  • Write an nginx module to process .aspx pages as thought they were html
  • Change recognized mimetypes and associate them with html
    • I tried adding application/aspx html htm shtml; to my nginx mimetype file and it didn't work.
  • Calling cgi to read the .aspx file and generate html which gets returned

My reason for asking this question is because I want to utilize an existing aspx-based web application. This aspx app doesn't have any c# specific code in the aspx files themselves, so it would greatly reduce my work.


Solution

  • This isn't the best solution, but I am developing a cgi application that will translate the REQUEST_URI for aspx pages into an open(file).read() and output the aspx page contents to the browser.

    I am developing an SSI parser to handle ssi calls, which so far is working for me but a little messy as it works for my setup only right now and has to redirect requests to SSI to my codebase instead of the .NET codebase based on file extension which is a poor solution.

    Ultimately, creating an nginx module to handle aspx as it would html and offload ssi to the nginx module would be the best solution methinks.

    Thanks to everyone who gave input, I know this question is definitely out in left field. Cheers.