Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC routing static file

I am working with a legacy swf file that is looking in the controller/action routing for a static route. For example, it is trying to download the file

http://localhost:59801/Resource/Details/ClearExternalPlaySeekMute.swf

When the file exists in the root directory:

http://localhost:59801/ClearExternalPlaySeekMute.swf

Can I use MapRoute to map this URL to the root directory?

like image 634
user547794 Avatar asked Oct 21 '22 20:10

user547794


2 Answers

You could use the url rewrite module in IIS. Once you install it simply add the following rewrite rule:

<system.webServer>
    <rewrite>
      <rules>
        <rule name="Rewrite Static Flash file" stopProcessing="true">
          <match url="^Resource/Details/ClearExternalPlaySeekMute.swf$" />
          <action type="Rewrite" url="ClearExternalPlaySeekMute.swf" />
        </rule>
      </rules>
    </rewrite>
</system.webServer>

Now when a request is made to /Resource/Details/ClearExternalPlaySeekMute.swf it will be served by /ClearExternalPlaySeekMute.swf.

like image 62
Darin Dimitrov Avatar answered Oct 24 '22 16:10

Darin Dimitrov


This should work for you, but I think this would be better through IIS.

routes.IgnoreRoute("{file}.swf");

I remember a SO post that was really good. If I find it, I'll be sure to reference.

Basically the same question... Using ASP.NET routing to serve static files

like image 32
MisterIsaak Avatar answered Oct 24 '22 15:10

MisterIsaak