Prefer application-relative or virtual-root paths. IIS can disable parent-path usage such as .. for security and application-boundary reasons.
Response.Write Server.MapPath("test.asp")
The output of the above line is here
Response.Write Server.MapPath("my_files/mappath.asp")
C:\Inetpub\wwwroot\my_files\my_files\mappath.aspResponse.Write Server.MapPath("/my_files/mappath.asp")
C:\Inetpub\wwwroot\my_files\mappath.asp
Response.Write Server.MapPath("/test.asp")
C:\Inetpub\wwwroot\test.aspResponse.Write Server.MapPath(".")
C:\Inetpub\wwwroot\my_filesResponse.Write Server.MapPath("/")
C:\Inetpub\wwwrootResponse.Write Server.HTMLEncode( "To highlight a string we have to add <b> Bold Tag </b>")
The output of this is here.
To highlight a string we have to add <b> Bold Tag </b>
Try to use only Response.Write without htmlencode and see the difference.
Response.Write Server.ScriptTimeout
We can change the above value like this.
Server.ScriptTimeout=10
By keeping this value at a lower level we can create some delays by writing some for loops.
Server.ScriptTimeout=1
Response.Write Server.ScriptTimeout
Dim i
For i=1 to 100000000
Next
Response.Write "<br>Done ...<br>"
This way we will create some delays and once it exceeds the ScriptTimeout value then we will get this error message.
Error Type:
Active Server Pages, ASP 0113 (0x80004005)
The maximum amount of time for a script to execute was exceeded. You can change this limit by specifying a new value for the property Server.ScriptTimeout or by changing the value in the IIS administration tools.
/a/server/scripttimeout.asp
<html><head>
<title>(Type a title for your page here)</title>
</head>
<body >
<%
Dim var1
var1=" My name is plus2net "
Response.Write " I am inside file1.asp file "
Response.Write " <br>---<br> "
Server.Transfer("file2.asp")
Response.Write " <br>---<br> "
Response.Write " I am back in main.asp file " & var1
%>
</body>
</html>
Now here is the code for file2.asp file
<%
Response.Write " I am in file2.asp inside "
%>
Once we run file1.asp file we will get the output like this
I am inside file1.asp file
---
I am in file2.asp inside
Here the main difference between Server.Execute and server.transfer is in case of server transfer the control does not return to main file again. In case of Server.Execute the script control returns to main file after executing the inner ( or file2.asp) file.
<html><head>
<title>(Type a title for your page here)</title>
</head>
<body >
<%
Dim var1
var1=" My name is plus2net "
Response.Write " I am inside main.asp file "
Response.Write " <br>---<br> "
Server.Execute("file2.asp")
Response.Write " <br>---<br> "
Response.Write " I am back in main.asp file " & var1
%>
</body>
</html>
Now here is the code for file2.asp file
<%
Response.Write " I am in file2.asp inside "
%>
Once we run main.asp file we will get the output like this
I am inside main.asp file
---
I am in file2.asp inside
---
I am back in main.asp file My name is plus2net
You can see the control has shifted to file2.asp file but after its execution again it returned to main.asp page. This is the main difference between Server.Execute and Server.Transfer command in ASP
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.