|
Home > Archive > IIS Server > December 2005 > how to get default webpage's name of IIS?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
how to get default webpage's name of IIS?
|
|
| iclinux 2005-12-27, 2:50 am |
| we can config IIS's default webpages such as: index.htm, index.asp,
default.asp, etc.
but how to get those names in a programming language?
best regards.
| |
| Kristofer Gafvert 2005-12-27, 2:50 am |
| Hello,
This is stored in the DefaultDoc property. An example using vbscript :
set vdirObj=GetObject("IIS://localhost/W3SVC/1")
WScript.Echo("DefaultDoc property value: " & vdirObj.DefaultDoc)
Also see:
http://www.microsoft.com/technet/pr...a69a47e895.mspx
--
Regards,
Kristofer Gafvert
http://www.gafvert.info/iis/ - IIS Related Info
iclinux wrote:
>we can config IIS's default webpages such as: index.htm, index.asp,
>default.asp, etc.
>
>but how to get those names in a programming language?
>
>best regards.
| |
| iclinux 2005-12-28, 2:54 am |
| thanks a lot, Kristofer Gafvert.
I implemented it in C++ as follow:
///////////////////////// CODE START //////////////////////////
BOOL GetDefaultDoc()
{
IADsContainer* iContainer = NULL;
IADs* iAds = NULL;
HRESULT hr = ADsGetObject(L"IIS://localhost/w3svc",
IID_IADsContainer, (void**)&iContainer);
if (SUCCEEDED(hr)) {
hr = iContainer->GetObject(_bstr_t("IIsWebServer"),
_bstr_t("1"), (IDispatch**)&iAds);
if (SUCCEEDED(hr)) {
VARIANT buf = { 0 };
if (S_OK == iAds->Get(_bstr_t("DefaultDoc"), &buf)) {
LogMessageW(V_BSTR(&buf)); // Log the default name
return TRUE;
}
}
}
return FALSE;
}
///////////////////////// CODE END //////////////////////////
But I have another question:
we can config the default webpage's name at least 3 places in IIS: the
first is the topmost, it contains all the websites; the second is
website in it; and the third is the virtual directory of a website.
how to get the default webpage's name in those three places?
in another words, how to get those names given a url such as
"http://localhost/DirectoryName/"?
Best Regards
| |
| Kristofer Gafvert 2005-12-28, 2:54 am |
| It is again stored in the DefaultDoc property, but you change:
IIS://localhost/w3svc
to
IIS://localhost/w3svc/1
or
IIS://localhost/w3svc/1/VirtualDirectoryName
where 1 is a valid website ID.
--
Regards,
Kristofer Gafvert
http://www.gafvert.info/iis/ - IIS Related Info
iclinux wrote:
>thanks a lot, Kristofer Gafvert.
>
>I implemented it in C++ as follow:
>
>///////////////////////// CODE START //////////////////////////
>BOOL GetDefaultDoc()
>{
> IADsContainer* iContainer = NULL;
> IADs* iAds = NULL;
>
> HRESULT hr = ADsGetObject(L"IIS://localhost/w3svc",
> IID_IADsContainer, (void**)&iContainer);
> if (SUCCEEDED(hr)) {
> hr = iContainer->GetObject(_bstr_t("IIsWebServer"),
> _bstr_t("1"), (IDispatch**)&iAds);
> if (SUCCEEDED(hr)) {
> VARIANT buf = { 0 };
> if (S_OK == iAds->Get(_bstr_t("DefaultDoc"), &buf)) {
> LogMessageW(V_BSTR(&buf)); // Log the default name
> return TRUE;
> }
> }
> }
>
> return FALSE;
>}
>///////////////////////// CODE END //////////////////////////
>
>But I have another question:
>we can config the default webpage's name at least 3 places in IIS: the
>first is the topmost, it contains all the websites; the second is
>website in it; and the third is the virtual directory of a website.
>
>how to get the default webpage's name in those three places?
>
>in another words, how to get those names given a url such as
>"http://localhost/DirectoryName/"?
>
>Best Regards
| |
| iclinux 2005-12-29, 2:51 am |
| Kristofer Gafvert, thanks again.
I've tried, but the follow two vbscripts displayed the same on my
pc(WinXP SP2, IIS5.1)
set vdirObj=GetObject("IIS://localhost/W3SVC/1")
WScript.Echo("DefaultDoc property value: " & vdirObj.DefaultDoc)
set vdirObj=GetObject("IIS://localhost/W3SVC")
WScript.Echo("DefaultDoc property value: " & vdirObj.DefaultDoc)
those two vbscript only got the default webpage name of "the topmost"
I mentioned above.
any help, or any documents about this?
regards
| |
| iclinux 2005-12-29, 2:51 am |
| forgot to say, the default webpage names of "the topmost" and "the
second" are different.
| |
| Kristofer Gafvert 2005-12-29, 2:51 am |
| I think i know what is going on.
You have changed the Default Document using IIS Manager, right? This
changes the DefaultDoc property of:
IIS://localhost/W3SVC/1/ROOT
So the DefaultDoc property of
IIS://localhost/W3SVC/1
has not been changed, and is the same as for
IIS://localhost/W3SVC
So try with the ROOT.
I would also recommend you to donwload IIS 6.0 Resource Kit Tools, and
install Metabase Explorer (works on Windows XP and Windows Server 2003)
This will help you understand the metabase, and you can verify if what is
returned by your code, matches with what is written in the metabase.
--
Regards,
Kristofer Gafvert
http://www.gafvert.info/iis/ - IIS Related Info
iclinux wrote:
>Kristofer Gafvert, thanks again.
>
>I've tried, but the follow two vbscripts displayed the same on my
>pc(WinXP SP2, IIS5.1)
>
>set vdirObj=GetObject("IIS://localhost/W3SVC/1")
>WScript.Echo("DefaultDoc property value: " & vdirObj.DefaultDoc)
>
>set vdirObj=GetObject("IIS://localhost/W3SVC")
>WScript.Echo("DefaultDoc property value: " & vdirObj.DefaultDoc)
>
>those two vbscript only got the default webpage name of "the topmost"
>I mentioned above.
>
>any help, or any documents about this?
>
>regards
| |
| iclinux 2005-12-30, 3:00 am |
| thanks a lot, Kristofer Gafvert: )
With your great help, I can get those names.
After installing IIS 6.0 Resource Kit Tools on my pc, I get a lot that
I didn't know from Metabase Explorer.
Now, I implemented a ISAPI Filter, and add it to a website. I tryied to
get the ID of that website, but failed...
Can a ISAPI Filter get the ID of the website which it's added in?
Greatly appreciate your kindness.
| |
| iclinux 2005-12-30, 3:00 am |
| Oh, I suddenly notice that there a 'Filter' in Metabase Explorer, it
should be what I want.
Sorry to trouble you 
|
|
|
|
|