Create a virtual directory (application pool in vb.net)
$30-100 USD
Cancelled
Posted over 17 years ago
$30-100 USD
Paid on delivery
I use windows 2003 standard with IIS 6.0.
I have this source code down here to create a virtual directory with application pool on a folder. But it only works on development server in visual studio 2005. It doesn't work on IIS 5.1 or 6.0. Give me some permission error. Here's the description following
Here's link to my ftp server for my source codes. <[login to view URL]>
## Deliverables
**[login to view URL]**
<% Page Language="VB" AutoEventWireup="false" CodeFile="[login to view URL]" Inherits="_Default" Debug="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[login to view URL]">
<html xmlns="[login to view URL]" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
**[login to view URL]**
Imports [login to view URL]
Imports System
Imports [login to view URL]
Imports [login to view URL]
Imports [login to view URL]
Imports [login to view URL]
Imports [login to view URL]
Imports [login to view URL]
Imports [login to view URL]
Imports [login to view URL]
Imports [login to view URL]
Imports [login to view URL]
Imports [login to view URL]
Partial Class _Default
Inherits [login to view URL]
Protected Sub Page_Load(ByVal sender As [login to view URL], ByVal e As [login to view URL]) Handles [login to view URL]
If Not IsPostBack Then
CreateVirtualDir("localhost", "test", "e:\test")
End If
End Sub
Private Sub CreateVirtualDir(ByVal WebSite As String, ByVal AppName As String, ByVal Path As String)
'Dim IISSchema As New [login to view URL]("IIS://" & WebSite & "/Schema/AppIsolated")
Dim IISSchema As New [login to view URL]("IIS://" & WebSite & "/Schema/AppIsolated", "Administrator", "1212")
Dim CanCreate As Boolean = Not [login to view URL]("Syntax").[login to view URL]() = "BOOLEAN"
[login to view URL]()
If CanCreate Then
Dim PathCreated As Boolean
Try
Dim IISAdmin As New [login to view URL]("IIS://" & WebSite & "/W3SVC/1/Root")
'make sure folder exists
If Not [login to view URL](Path) Then
[login to view URL](Path)
PathCreated = True
End If
'If the virtual directory already exists then delete it
For Each VD As [login to view URL] In [login to view URL]
If [login to view URL] = AppName Then
[login to view URL]("Delete", New String() {[login to view URL], AppName})
[login to view URL]()
Exit For
End If
Next VD
'Create and setup new virtual directory
Dim VDir As [login to view URL] = [login to view URL](AppName, "IIsWebVirtualDir")
[login to view URL]("Path").Item(0) = Path
[login to view URL]("AppFriendlyName").Item(0) = AppName
[login to view URL]("EnableDirBrowsing").Item(0) = False
[login to view URL]("AccessRead").Item(0) = True
[login to view URL]("AccessExecute").Item(0) = True
[login to view URL]("AccessWrite").Item(0) = False
[login to view URL]("AccessScript").Item(0) = True
[login to view URL]("AuthNTLM").Item(0) = True
[login to view URL]("EnableDefaultDoc").Item(0) = True
[login to view URL]("DefaultDoc").Item(0) = "[login to view URL],[login to view URL],[login to view URL]"
[login to view URL]("AspEnableParentPaths").Item(0) = True
[login to view URL]()
'the following are acceptable params
'INPROC = 0
'OUTPROC = 1
'POOLED = 2
[login to view URL]("AppCreate", 1)
Catch Ex As Exception
If PathCreated Then
[login to view URL](Path)
End If
Throw Ex
End Try
End If
End Sub
End Class
**Error on <http://localhost/[login to view URL]>**
Access denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.UnauthorizedAccessException.
**Source Error:**
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
**Stack Trace:**
[UnauthorizedAccessException: Access denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))]
[login to view URL](String WebSite, String AppName, String Path) +1238
_Default.Page_Load(Object sender, EventArgs e) +43
[login to view URL](EventArgs e) +99
[login to view URL]() +47
[login to view URL](Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
## Platform
windows 2003 standard sp 1 with visual studio 2005 and sql 2005.
IIs 6