M
MRUTYUNJAYA.M
Guest
I am working in installer. I need to create one application/Virtual Directory under my own "MySite" . it is not under "Default Web Site". following are code using for same..But I am unable to create. My requirement is as below in IIS.
sites
MySite
TestApp
reports
Default Web Site.
asp-net
My requirement is to create TestApp entry and Virtual directory for this under MySite. I am able to create under Default Web Site but unable to create under MySite. Can anybody please suggest ?
physicalPath = "AM\\MH"
virtualpath = "TestApp"
altVirtualPath = "reports"
HRESULT CreateIIS7VirtualDirectory(BSTR physicalPath, BSTR virtualPath, BSTR altVirtualPath)
{
CComPtr<IAppHostWritableAdminManager> adminManager;
HRESULT hr = adminManager.CoCreateInstance(__uuidof(AppHostWritableAdminManager));
if(FAILED(hr))
return hr;
CComBSTR sitesSection("system.applicationHost/sites");
CComBSTR path("MACHINE/WEBROOT/APPHOST/MySite");
CComPtr<IAppHostElement> sitesElement;
hr = adminManager->GetAdminSection(sitesSection, path, &sitesElement);
CComPtr<IAppHostElement> siteElement;
hr = GetSiteElement(sitesElement, siteElement);
CComPtr<IAppHostElementCollection> applications;
hr = siteElement->get_Collection(&applications);
CComPtr<IAppHostElement> application;
hr = GetApplicationElement(virtualPath, applications, application);
hr = SetApplicationVirtualDirectory(application, physicalPath, CComBSTR("/"));
SetApplicationVirtualDirectory(application, physicalPath, altVirtualPath);
hr = adminManager->CommitChanges();
SetApplicationPermissions(virtualPath);
return S_OK;
}
Continue reading...
sites
MySite
TestApp
reports
Default Web Site.
asp-net
My requirement is to create TestApp entry and Virtual directory for this under MySite. I am able to create under Default Web Site but unable to create under MySite. Can anybody please suggest ?
physicalPath = "AM\\MH"
virtualpath = "TestApp"
altVirtualPath = "reports"
HRESULT CreateIIS7VirtualDirectory(BSTR physicalPath, BSTR virtualPath, BSTR altVirtualPath)
{
CComPtr<IAppHostWritableAdminManager> adminManager;
HRESULT hr = adminManager.CoCreateInstance(__uuidof(AppHostWritableAdminManager));
if(FAILED(hr))
return hr;
CComBSTR sitesSection("system.applicationHost/sites");
CComBSTR path("MACHINE/WEBROOT/APPHOST/MySite");
CComPtr<IAppHostElement> sitesElement;
hr = adminManager->GetAdminSection(sitesSection, path, &sitesElement);
CComPtr<IAppHostElement> siteElement;
hr = GetSiteElement(sitesElement, siteElement);
CComPtr<IAppHostElementCollection> applications;
hr = siteElement->get_Collection(&applications);
CComPtr<IAppHostElement> application;
hr = GetApplicationElement(virtualPath, applications, application);
hr = SetApplicationVirtualDirectory(application, physicalPath, CComBSTR("/"));
SetApplicationVirtualDirectory(application, physicalPath, altVirtualPath);
hr = adminManager->CommitChanges();
SetApplicationPermissions(virtualPath);
return S_OK;
}
Continue reading...