Couple of IIS 7.5 API questions

T

taltene

Hi all.

This is regarding the IIS 7.5 API.

1. Does someone know how to set an application pool LoadUserProfile value?

I couldn't even find this attribute as part of the ApplicationPoolDefaults Class members.

2. I wrote the following in order to set Site Browsing to true:

using (m_serverManager)
{
Configuration config = m_serverManager.GetWebConfiguration(m_sSiteName);

ConfigurationSection directoryBrowseSection = config.GetSection("system.webServer/directoryBrowse");
directoryBrowseSection["enabled"] = true;

m_serverManager.CommitChanges();
}

But right after that the server manager object was disposed! Why?

Thanks!
 
J

Jeff Johnson

2. I wrote the following in order to set Site Browsing to true:

using (m_serverManager)
{

Did that actually compile? I was under the impression that you had to
declare and set a variable inside the parentheses of a using statement.

Regardless, if it did compile, I'll tell you why m_serverManager was
disposed afterwards: because that's what the using statement does! In fact,
that's the entire purpose of the construct. What did you hope to gain from
using using, if not that? (There's some awkward phrasing.)

Your question was akin to saying, "I put x-- in my code and after it
executed, x was 1 less than it was before! Why?"
 
J

Jeff Johnson

I was under the impression that you had to declare and set a variable
inside the parentheses of a using statement.

Wow, I must be blind. I specifically looked up using in MSDN before posting
and I COMPLETELY missed this example:

Font font2 = new Font("Arial", 10.0f);
using (font2) // not recommended
{
// use font2
}
// font2 is still in scope
// but the method call throws an exception
float f = font2.GetHeight();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top