request.serverVariables()“URL”vs“Script_Name”

时间:2022-03-22 05:30:42

I am maintaining a classic asp application and while going over the code I came across two similar lines of code:

我正在维护一个经典的asp应用程序,在查看代码时,我遇到了两行类似的代码:

Request.ServerVariables("URL")
' Output: "/path/to/file.asp"

Request.ServerVariables("SCRIPT_NAME")
' Output: "/path/to/file.asp"

I don't get it... what is the difference? both of them ignore the URL rewriting that I have set up which puts the /path folder as the root document (the above URL is rewritten to "/to/file.asp")

我不明白......有什么区别?他们都忽略我设置的URL重写,它将/ path文件夹作为根文档(上面的URL被重写为“/to/file.asp”)

More info: The site is deployed on IIS 7

更多信息:该站点部署在IIS 7上

3 个解决方案

#1


This could be a bug under IIS 7.

这可能是IIS 7下的一个错误。

I could not get Request.ServerVariables("URL") and Request.ServerVariables("SCRIPT_NAME") to return different values. I've tried the cases where they were called from an included file (<!--#include file="file.asp"-->) or after a Server.Transfer.

我无法获取Request.ServerVariables(“URL”)和Request.ServerVariables(“SCRIPT_NAME”)以返回不同的值。我已经尝试过从包含文件( )或在Server.Transfer之后调用它们的情况。

#2


URL Gives the base portion of the URL, without any querystring or extra path information. For the raw URL, use HTTP_URL or UNENCODED_URL.

URL提供URL的基本部分,不包含任何查询字符串或额外路径信息。对于原始URL,请使用HTTP_URL或UNENCODED_URL。

SCRIPT_NAME A virtual path to the script being executed. Can be used for self-referencing URLs.

SCRIPT_NAME正在执行的脚本的虚拟路径。可用于自引用URL。

See, http://www.requestservervariables.com/url and /script_name for the definitions.

有关定义,请参阅http://www.requestservervariables.com/url和/ script_name。

#3


Is this maybe there in case of Server.Transfer?

这可能是Server.Transfer的情况吗?

In the case where you do a server.transfer i think you would get different results

在你做server.transfer的情况下,我认为你会得到不同的结果

i.e. SCRIPT_NAME would be e.g. /path/to.transferredfile.asp whereas URL would remain as /path/to/file.asp

即SCRIPT_NAME将是例如/path/to.transferredfile.asp,而URL将保留为/path/to/file.asp

#1


This could be a bug under IIS 7.

这可能是IIS 7下的一个错误。

I could not get Request.ServerVariables("URL") and Request.ServerVariables("SCRIPT_NAME") to return different values. I've tried the cases where they were called from an included file (<!--#include file="file.asp"-->) or after a Server.Transfer.

我无法获取Request.ServerVariables(“URL”)和Request.ServerVariables(“SCRIPT_NAME”)以返回不同的值。我已经尝试过从包含文件( )或在Server.Transfer之后调用它们的情况。

#2


URL Gives the base portion of the URL, without any querystring or extra path information. For the raw URL, use HTTP_URL or UNENCODED_URL.

URL提供URL的基本部分,不包含任何查询字符串或额外路径信息。对于原始URL,请使用HTTP_URL或UNENCODED_URL。

SCRIPT_NAME A virtual path to the script being executed. Can be used for self-referencing URLs.

SCRIPT_NAME正在执行的脚本的虚拟路径。可用于自引用URL。

See, http://www.requestservervariables.com/url and /script_name for the definitions.

有关定义,请参阅http://www.requestservervariables.com/url和/ script_name。

#3


Is this maybe there in case of Server.Transfer?

这可能是Server.Transfer的情况吗?

In the case where you do a server.transfer i think you would get different results

在你做server.transfer的情况下,我认为你会得到不同的结果

i.e. SCRIPT_NAME would be e.g. /path/to.transferredfile.asp whereas URL would remain as /path/to/file.asp

即SCRIPT_NAME将是例如/path/to.transferredfile.asp,而URL将保留为/path/to/file.asp