We are porting a Classic ASP app to ASP.NET. What do we do about the #INCLUDE (.inc) files? Now they're causing build errors because ASP.NET thinks the variables are "not declared".
我们正在将一个经典的ASP应用程序移植到ASP.NET中。我们如何处理#INCLUDE (.inc)文件?现在因为ASP而导致了构建错误。NET认为变量是“未声明的”。
2 个解决方案
#1
2
You haven't stated what is in the .inc files. Lets assume there are a bunch of const definitions and a few helper functions.
您还没有说明.inc文件中的内容。假设有一堆const定义和一些辅助函数。
There are a couple of variations that you might consider.
你可以考虑一些变化。
- Often there is a single .inc which gets included in all or most ASP pages.
- 通常只有一个.inc包含在所有或大部分ASP页面中。
- Other .inc files get included in a few ASP pages because they just encapsulate some shared functionality.
- 其他的.inc文件被包含在几个ASP页面中,因为它们只是封装了一些共享的功能。
For variation 1 it might help to create a class that derives from Page
that exposes the original .inc files constants as properties and its functions as methods. Have all the ported ASP to ASP.NET pages inherit from this new class rather than directly from Page
.
对于变体1,它可能有助于创建一个类,该类派生自页面,该页面将原始的.inc文件常量公开为属性,并将其函数公开为方法。将所有的ASP移植到ASP。NET页面从这个新类继承而不是直接从Page继承。
For variation 2 create classes in App_Code that contain static properties and methods (or direct ports of VBScript classes if that's what the .inc contained). The ASP to ASP.NET page ports that use these includes would need to prefix their usage of members from the original .inc file with the name of the class of which they are not static (shared) members.
对于变体2,在App_Code中创建包含静态属性和方法的类(如果这是.inc所包含的,则可以直接使用VBScript类的端口)。ASP的ASP。使用这些include的NET页面端口需要在原始.inc文件中为其成员的使用加上前缀,该文件的名称不是静态(共享)成员。
If the includes originally contain static markup then a better port for those is to create representative .master pages and have the ported ASP pages use those masters appropriately.
如果include最初包含静态标记,那么更好的端口是创建具有代表性的.master页面,并让所移植的ASP页面适当地使用这些master。
#2
1
You can port them in the same way you did in ASP:
你可以像在ASP中那样移植它们:
<!--#include virtual="/include/flash-check_inc.asp"-->
#1
2
You haven't stated what is in the .inc files. Lets assume there are a bunch of const definitions and a few helper functions.
您还没有说明.inc文件中的内容。假设有一堆const定义和一些辅助函数。
There are a couple of variations that you might consider.
你可以考虑一些变化。
- Often there is a single .inc which gets included in all or most ASP pages.
- 通常只有一个.inc包含在所有或大部分ASP页面中。
- Other .inc files get included in a few ASP pages because they just encapsulate some shared functionality.
- 其他的.inc文件被包含在几个ASP页面中,因为它们只是封装了一些共享的功能。
For variation 1 it might help to create a class that derives from Page
that exposes the original .inc files constants as properties and its functions as methods. Have all the ported ASP to ASP.NET pages inherit from this new class rather than directly from Page
.
对于变体1,它可能有助于创建一个类,该类派生自页面,该页面将原始的.inc文件常量公开为属性,并将其函数公开为方法。将所有的ASP移植到ASP。NET页面从这个新类继承而不是直接从Page继承。
For variation 2 create classes in App_Code that contain static properties and methods (or direct ports of VBScript classes if that's what the .inc contained). The ASP to ASP.NET page ports that use these includes would need to prefix their usage of members from the original .inc file with the name of the class of which they are not static (shared) members.
对于变体2,在App_Code中创建包含静态属性和方法的类(如果这是.inc所包含的,则可以直接使用VBScript类的端口)。ASP的ASP。使用这些include的NET页面端口需要在原始.inc文件中为其成员的使用加上前缀,该文件的名称不是静态(共享)成员。
If the includes originally contain static markup then a better port for those is to create representative .master pages and have the ported ASP pages use those masters appropriately.
如果include最初包含静态标记,那么更好的端口是创建具有代表性的.master页面,并让所移植的ASP页面适当地使用这些master。
#2
1
You can port them in the same way you did in ASP:
你可以像在ASP中那样移植它们:
<!--#include virtual="/include/flash-check_inc.asp"-->