【问题标题】:Issue with .inc file on converting from asp to asp.net从 asp 转换为 asp.net 时 .inc 文件出现问题
【发布时间】:2014-01-21 19:01:22
【问题描述】:

我正在将一个 asp 页面转换为 asp.net。在登录页面中我有 3 个包含文件

<!-- #include file="includes/const.inc" -->    
<!-- #include file="includes/ShiftFuncs.inc" -->
<!-- #INCLUDE FILE="includes/xmlutil.asp" -->

在 ShiftFunc.inc 中有一组代码,它还包括另一个 inc 文件

Option Explicit

Response.AddHeader "Expires", "Fri, Jun 12, 1981 08:20"

Response.AddHeader "Cache-Control", "no-cache"

Response.AddHeader "Pragma", "No-Cache"

Response.Buffer = True

If IsEmpty( Session("user") ) Then

    Response.Write "<SCRIPT>" & chr(13) & chr(10) & "top.location.href='login.asp'" & chr(13) & chr(10) & "</SCRIPT>" & chr(13) & chr(10)

    Response.Redirect("login.asp")

End If

'Response.Write "User: " & Session("user") & "<BR>" & crlf
%>
<!-- #include file="globals.inc" -->

转换 inc 文件的最佳方法是什么?我需要为此创建一个类吗?或者只是将这些文件转换为 aspx 页面然后包含它?

提前致谢!

【问题讨论】:

    标签: asp.net vb.net asp-classic include


    【解决方案1】:

    这段代码似乎包含http meta tags,控制页面的缓存,检查用户是否登录的代码以及对包含常量和实用函数的其他文件的引用。

    缓存控制标头都可以轻松添加到您网站的 asp.net 版本中的Master page

    如果您要重用 Session("user") 方法以及您拥有的任何登录/用户管理页面,也可以在主页面中执行用户登录检查,但您最好重新设计它与Asp.net membership providerforms authentication 之类的东西一起使用,可以为您提供更多特性和功能。

    globals.inc 和 const.inc 中包含的常量可以在新的 vb.net 类中复制,可能是 enums?而 xmlutil.asp 中的函数,如果在 .net 世界中仍然需要它们,我肯定可以在新的 vb.net 类中将它们复制为静态方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多