CODEDIGEST
Home » Articles
Search
 

Technologies
 

CodeDigest Navigation
 

Technology News
No News Feeds available at this time.
 

Community News
No News Feeds available at this time.
 
VBScript code for setting HttpRedirect Property for a IIsWebFile programmatically

By Rakki Muthukumar
Posted On Feb 20,2008
Article Rating:
Be first to rate
this article.
No of Comments: 1
Category: IIS
Print this article.

VBScript code for setting HttpRedirect Property for a IIsWebFile programmatically

I was helping one of my colleague whose customer wanted a custom VBScript file which sets redirection for certain files under a virtual directory. He wanted to use VBScript alone to achieve this.

A IIsWebFile node will be created in the metabase only when you specifically set a property for the file like HttpRedirect through the IIS manager UI. The below script, gets the IIsWebVirtualDir object of the virtual directory we are interested in, creates a IIsWebFile node and sets it HttpRedirect property:



 

' Virtual Directory under which you need to create the IIsWebFile

vDirName = "IIS://localhost/w3svc/1/root/artinstitutes"

' Getting the Virtual Directory (IIsWebVirDir object)

Set IIsWebVirtualDirObj = GetObject(vDirName)

 

' Call the CreateAWebFile function and pass the IIsWebVirDir object we have with the file name and the redirect url

CreateAWebFile(IIsWebVirtualDirObj, "test.html", "/check.asp?id=0")

CreateAWebFile(IIsWebVirtualDirObj, "test1.html","/check.asp?id=1”)

 

' Commit the changes to the Metabase

IIsWebVirtualDirObj.SetInfo()

 

' This function takes 3 arguments

' 1 = IISObject – the container object

' 2 = filename – physical FileName which needs to be redirected

' 3 = redirectFileName – redirect URL

Function CreateAWebFile(ByVal IISObject, ByVal fileName, ByVal redirectName)

 

    Set myFileCheck = GetObject(vDirname & "/" & fileName)

 

    If (Err.Number <> 0) Then

        Set myFile = IISObject.Create("IIsWebFile", fileName)

        myFile.HttpRedirect = redirectName & " ,PERMANENT"

        myFile.SetInfo()

    Else

        myFileCheck.HttpRedirect = redirectName & " ,PERMANENT"

        myFileCheck.SetInfo()

    End If

 

End Function

Hope this helps!

Similar Articles
You can contribute to CodeDiget.Com:
Donate to CodeDigest.com
Article Feedback
Comments
i got this from an online socureYes, Pure ASP Upload supports uploading large files on the Windows 2003 server. However:IIS6.0 prevent the upload of files more than +200Kb. So you need to make some ch
i got this from an online socureYes, Pure ASP Upload supports uploading large files on the Windows 2003 server. However:IIS6.0 prevent the upload of files more than +200Kb. So you need to make some changes in the default IIS settings first.BackgroundFor IIS6.0 users, the AspMaxRequestEntityAllowed property specifies the maximum number of bytes allowed in the entity body of an ASP request. If a Content-Length header is present and specifies an amount of data greater than the value of AspMaxRequestEntityAllowed, IIS returns a 403 error response.This property is related in function to MaxRequestEntityAllowed, but is specific to ASP request. Whereas you might set the MaxRequestEntityAllowed property to 1 MB at the general World Wide Web Publishing Service (WWW Service) level, you may choose to set AspMaxRequestEntityAllowed to a lower value, if you know that your specific ASP applications handle a smaller amount of data.SolutionOpen your metabase.XML which is located in c:\Windows\System32\Inetsrv find the line AspMaxRequestEntityAllowed and change it to 1073741824 . This is 1GB of course you can enter another value to suite your needs.NOTE: Before you edit the file, be sure to stop the IIS service first or else you won't be able to save the file.