将ASP.NET MVC 2与经典ASP集成

时间:2022-04-27 01:38:12

I'm in the process of moving a large classic ASP application to ASP.NET MVC 2. Questions:

我正在将大型经典ASP应用程序移动到ASP.NET MVC 2。

My question is about project organization.

我的问题是关于项目组织。

I would prefer to not mix the MVC code with the ASP code in the same VS project. I'd like to have an MVC WAP with areas that match the parts of the website that I'm migrating. For instance, the old site has a folder

我宁愿不将MVC代码与同一VS项目中的ASP代码混合使用。我想要一个MVC WAP,其区域与我正在迁移的网站部分相匹配。例如,旧站点有一个文件夹

/products/default.asp.....

/products/productName/default.asp

etc.

In the MVC WAP, I'd like to have an area called "products", which I could then, either through a rewrite, routing, or preferably through some IIS configuration, point the "products" folder on the ASP site to. In this way, I could gradually move root folders from the ASP site to the MVC application.

在MVC WAP中,我想要一个名为“产品”的区域,然后我可以通过重写,路由或最好通过某些IIS配置,将ASP站点上的“products”文件夹指向。通过这种方式,我可以逐步将根文件夹从ASP站点移动到MVC应用程序。

However, if I create the MVC WAP in a virtual folder, then my routes wind up looking like

但是,如果我在虚拟文件夹中创建MVC WAP,那么我的路线看起来就像

http://localhost/virtualFolder/products

instead of

http://localhost/products

Any suggestions on how to conquer this?

关于如何征服这个的任何建议?

I know that, during deployment, I could deploy the MVC WAP into the root of the ASP site, but this doesn't help with debugging.

我知道,在部署期间,我可以将MVC WAP部署到ASP站点的根目录中,但这对调试没有帮助。

1 个解决方案

#1


1  

I'll write my answer assuming this is hosted on an IIS7 instance. If it's IIS6, then you'll need to look for a suitable ModRewrite module for it.

假设它托管在IIS7实例上,我会写下我的答案。如果它是IIS6,那么你需要为它寻找合适的ModRewrite模块。

So, assuming IIS7, you'll be far better off using URL Rewrite: http://learn.iis.net/page.aspx/460/using-the-url-rewrite-module/

因此,假设使用IIS7,使用URL重写会更好:http://learn.iis.net/page.aspx/460/using-the-url-rewrite-module/

You can manage your rewrite rules and rewrite maps, depending on your level of access and control, either from within the IIS7 Administration Console, or manually via your web.config file.

您可以在IIS7管理控制台中管理重写规则并重写映射,具体取决于您的访问和控制级别,也可以通过web.config文件手动管理。

These rewrite rules and maps can be as simple or complex as you need them to be. You can also set them up to be either a temporary or permanent redirect - which will assist if any search engines are indexing the site as the correct redirect code will be returned with the HTTP request to ensure crawler results are updated promptly.

这些重写规则和映射可以像您需要的那样简单或复杂。您还可以将它们设置为临时或永久重定向 - 这将有助于任何搜索引擎索引网站,因为将返回带有HTTP请求的正确重定向代码,以确保快速更新爬网程序结果。

#1


1  

I'll write my answer assuming this is hosted on an IIS7 instance. If it's IIS6, then you'll need to look for a suitable ModRewrite module for it.

假设它托管在IIS7实例上,我会写下我的答案。如果它是IIS6,那么你需要为它寻找合适的ModRewrite模块。

So, assuming IIS7, you'll be far better off using URL Rewrite: http://learn.iis.net/page.aspx/460/using-the-url-rewrite-module/

因此,假设使用IIS7,使用URL重写会更好:http://learn.iis.net/page.aspx/460/using-the-url-rewrite-module/

You can manage your rewrite rules and rewrite maps, depending on your level of access and control, either from within the IIS7 Administration Console, or manually via your web.config file.

您可以在IIS7管理控制台中管理重写规则并重写映射,具体取决于您的访问和控制级别,也可以通过web.config文件手动管理。

These rewrite rules and maps can be as simple or complex as you need them to be. You can also set them up to be either a temporary or permanent redirect - which will assist if any search engines are indexing the site as the correct redirect code will be returned with the HTTP request to ensure crawler results are updated promptly.

这些重写规则和映射可以像您需要的那样简单或复杂。您还可以将它们设置为临时或永久重定向 - 这将有助于任何搜索引擎索引网站,因为将返回带有HTTP请求的正确重定向代码,以确保快速更新爬网程序结果。