learning... learning... - 1 year ago 35
ASP.NET (C#) Question

how can i include classic asp pages inside MVC project

We have a classic asp site (not asp.net) that we have been migrating over to MVC bit by bit. Currently MVC project runs as an application under classic asp in IIS, with its own app pool. This arrangement is working.

I have been told to look into running the remainder of the classic asp pages from inside MVC project, making the MVC project the main project in IIS.

I have been searching for a viable solution but haven't found any yet. This question is very similar to mine but there are no answers.

Can i create a folder (classicasp) inside the MVC project, move my remaining active classic asp pages to this folder and then run these from here? The url will be like


Is it possible? If yes, how will i handle the MVC routing to point to classic asp pages?

Or should I reverse the arrangement and run classic asp site as an application under MVC in IIS???

Please let me know if you need more information.

Answer Source

You can put classic asp pages in your root folder in your mvc site (or a sub folder within the root folder), so yes, the url http://www.somewebsite.com/classicasp/somepage.asp should work if the location of the file is along the lines of C:\path-to\root\classicasp\somepage.asp

As far as routing goes, don't do it with MVC, use the IIS rewrite module

You're probably better off using the module to generate the rules rather than writing them into web.config directly, but here's what a sample rule would look like in web.config. It enables you to find an article at mysite.com/article.asp?id=10 with the url mysite.com/article/10

                <rule name="RewriteUserFriendlyURL1" stopProcessing="true">
                    <match url="^article/([^/]+)/?$" />
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    <action type="Rewrite" url="article.asp?id={R:1}" />