Old Classic ASP pages getting caught in MVC Route

允我心安 提交于 2019-12-06 15:56:45

Have you tried to use web.config?

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Remove index.php" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
                    <match url="^(.*)$" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

The example above is used to rewrite a CodeIgniter app to omit the index.php file from the URL. You can do many things with it, considering the conditions part. In this case, I only do the rewriting if it's not a file and not a directory.

OK, after hours and hours of reading/researching/debugging, I came to the conclusion that I wasn't doing anything wrong and that there was something "buggy" in Visual Studio, .NET, MVC ... something! And I was right! I created a new project from scratch, copied all my code over there and everything worked as it should!

(Well, I'm not sure "as it should" is correct, but I did get my code to function the way I wanted. Requests for ASP pages still hit the MvcApplication_BeginRequest - which I don't think they should with my IgnoreRoute entries???? - but at least the extension was still there when it got there, so I could look-up the ASP page in my database and do the redirect!)

So, this may have been unique to me, but maybe I can save others hours of frustration ... if you think you have everything correct, maybe you do! Create a new project and try that!

... It sucks to be a programmer! ;-D

(Musings ... The 3 things that I didn't add back into my new project were:

  1. the logging tool ELMAH
  2. the RouteMagic DLL
  3. and the RouteDebugger.dll.

I may try subtracting them from my original project and see how that goes. Given the popularity of ELMAH and who wrote the route ones, I can't imagine that there would be a problem with them, but who knows ...?)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!