摘要载入中…    请稍等…












内容载入中…    请稍等…

如长时间看不到内容,请关闭浏览器,重新打开此页!

芯友首页 应用软件 编程开发 网络硬件 资源下载 动漫音乐 精美图库 芯友论坛 视频教程 电脑技术QQ群:72845454
 ★★photoshop学友-史上最强播放器★★
 位置:网络硬件>服务器配置>IIS常见问题
◎→ 本类最新
清除iis缓存
IIS提供的服务
IIS的软件要求
IIS的使用
已经装了WIN2000和IIS5以及PWS,
IIS Application Identities - I
IIS 6 常见问题解答
◎→相关资源
电脑软硬件入门视频教程
局域网基础视频教程
IIS常见问题
电脑组装
电脑配件
BIOS与CMOS故障
IIS常见问题
Web服务器
邮件服务器
黑客技术与网络安全视频
◎→ 热门资源
DCOM用的,参考www.microsoft.com
如何监视和提高IIS 5.0的性能
如何提高IIS 5.0网站伺服器的执行
为什么IIS无法正常启动?
IIS5.0中EXECUTE的巧用
也不贴上,用ASP开发基于Windows
让IIS 5.0的错误信息提示更详细的

IIS 更新ScriptMaps


日期:2008-10-20 18:01:02    来源:互联网
   

A zip file with your code and stylesheet is also available for download. Make sure you right click on the link and choose Save Target As...

To use the colored code in your pages link to the stylesheet colorcode.css and copy everything between the <pre tags. Feel free to modify color assignment in the stylesheet as you wish.


--------------------------------------------------------------------------------

//**************************************
// for :Dynamic ScriptMapping with Metabase
//**************************************
Copyright (c) 2003, Lewis Moten. All rights reserved.
//**************************************
// Name: Dynamic ScriptMapping with Metabase
// Description:Allows you to assign almost any extension to be processed by the ASPX script processor. You may add, update, and remove the extension progromatically without opening the IIS Manager. Great for those of you who do not have access to the machines desktop (such as hosted at other ISPs).
// By: Lewis E. Moten III
//
//
// Inputs:None
//
// Returns:None
//
//Assumes:None
//
//Side Effects:None
//This code is copyrighted and has limited warranties.
//Please see http://www.Planet-Source-Code.com/xq/ASP/txtCodeId.1586/lngWId.10/qx/vb/scripts/ShowCode.htm
//for details.
//**************************************

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ext As String = "GIF"
' Setup extension to be processed by ASPX script processor
Response.Write("&lt;BR>Add: " & Mapping(ext, MappingAction.Add))
' Update extension to be processed by latest ASPX script processor
Response.Write("&lt;BR>Update: " & Mapping(ext, MappingAction.Update))
' Setup extension so that it is not processed by any script processor
Response.Write("&lt;BR>Delete: " & Mapping(ext, MappingAction.Delete))
End Sub
Enum MappingAction
Add
Update
Delete
End Enum
Private Function Mapping(ByVal ext As String, ByVal action As MappingAction) As Boolean
' Assigns the ASPX processor to the extension specified.
' See IIS documentation for information regarding script mapping
' http://localhost/iishelp/iis/htm/asp/apro9tkj.htm
' Example of Script Mapping:
' ".gif,C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG"
Dim APPL_MD_PATH As String
Dim AppPath As String
Dim App As DirectoryEntry
Dim ScriptMaps As ArrayList
Dim ExtentionExists As Boolean = False
Dim ScriptProcessor As String = ""
Dim Flags As String = "5"
Dim IncludedVerbs As String = "GET,POST,HEAD"
Dim NewMap As String = "{0},{1},{2},{3}"
' Make sure ext is prefixed with "."
If Not ext.IndexOf(".") = 0 Then ext = "." & ext
' Make sure ext is lowercase
ext = ext.ToLower
' Do our best to prevent problems with default script processors
Dim BadExt As String
BadExt = ".asa.asax.ascx.ashx.asmx.asp.aspx.asd.cdx.cer.config."
BadExt &= "cs.csproj.idc.java.jsl.licx.rem.resources.resx.shtm."
BadExt &= "shtml.soap.stm.vb.vbproj.vjsproj.vsdisco.webinfo."
If Not BadExt.IndexOf(ext & ".") = -1 Then
Return False
End If
Response.Write("got here!")
Response.End()
' Get Application metadata path
APPL_MD_PATH = Request.ServerVariables("APPL_MD_PATH").ToString
' Format path for ADSI
AppPath = Replace(APPL_MD_PATH, "/LM/", "IIS://localhost/")
' Attempt to acquire the object
Try
If DirectoryEntry.Exists(AppPath) Then
App = New DirectoryEntry(AppPath)
End If
Catch ex As Exception
Return False
End Try
' Get a list of all script mappings
ScriptMaps = New ArrayList(CType(App.Properties("ScriptMaps").Value, Object()))
' If we are not deleting a script map
If Not action = MappingAction.Delete Then
' We need to get the latest processor installed
' that handles aspx pages.
For Each Map As String In ScriptMaps
' if the first value of the string is an ASPX page
If Split(Map, ",", 4)(0) = ".aspx" Then
' The latest script processor is the second
' value in the comma delimited string
ScriptProcessor = Split(Map, ",", 4)(1)
Exit For
End If
Next
' Processor not found!
If ScriptProcessor = "" Then
App.Dispose()
App = Nothing
Return False
End If
End If
' Find out if extension exists
For index As Integer = 0 To ScriptMaps.Count() - 1
' get current map
Dim map As String = ScriptMaps(index).ToString
' if we found the extension
If Split(Map, ",", 4)(0) = ext Then
' Determine results based on action
If action = MappingAction.Add Then
' impossible to add if it exists
App.Dispose()
App = Nothing
Return False
ElseIf action = MappingAction.Update Then
' update the map with latest script processor
ScriptMaps(index) = NewMap.Format(NewMap, ext, ScriptProcessor, Flags, IncludedVerbs)
Exit For
ElseIf action = MappingAction.Delete Then
' delete the map
ScriptMaps.RemoveAt(index)
Exit For
End If
End If
Next
' Is user attempting to add map?
If action = MappingAction.Add Then
' Build the new map
ScriptMaps.Add(NewMap.Format(NewMap, ext, ScriptProcessor, Flags, IncludedVerbs))
End If
' Save the new set of script maps
App.Properties("ScriptMaps").Value = ScriptMaps.ToArray
App.CommitChanges()
App.Dispose()
App = Nothing
Return True
End Function
 
 [1]
Tags: 

芯友网版权所有 1999-2006 | 著作权与商标声明 | 法律声明 | 服务条款 | 隐私声明 | 联系我们