Archives

Archives / 2008
  • LogParser – Useful Logparser scripts

    Logparser is a powerful utility which comes handy for me whenever I’m helping my customers facing a problem with slow running pages, frequently hit pages, post mortem analysis to find what went wrong on IIS, et al. You can use Logparser to parse your IIS logs to health check the state of your server, and the requests it had served. Below are few LogParser scripts, and their corresponding output in chart format – you can choose your own format, but isn’t a picture worth a 1000 words?

  • IIS7 – ASP.NET on Windows Server 2008 Server Core R2

    If you are a Server Core fan, and wished you could host ASP.NET websites in Server Core, then feel better, you wish had come true. Windows Server 2008 R2’s Server Core will have .NET Framework which means, ASP.NET too. This is a big news for all those wanted to deploy Server Core, but stopped because .NET Fx wasn’t there in the RTM release.

  • IIS7 – How to set up logging to a remote UNC share?

    First of all, let me tell you that there isn’t much changes to the logging done to IIS 7.0 compared to IIS 6.0. Logging still happens through Http.Sys, and you can configure the logging directory (of FREB log directory) to be a UNC share. There are a few MSDN/Technet articles available for the same(for IIS 6.0), but here I’ve tried to keep the steps simple, together at one place, and few steps specific to IIS 7.0.

  • ASP.NET 2.0 x64 – You may get HTTP 400 Bad Request or Error as mentioned in KB 932552 or 826437

    I’m sure you already know about this fix for ASP.NET which fixes an issue of “not a valid path” exception, and this fix for ASP.NET 1.1 for the same reason. If you receive this error now on your application, you might not need to apply the hotfix because your ASP.NET version might be higher than the one available with this hotfix, so verify the DLL versions before even requesting the hotfix from Microsoft.

  • IIS7 – Enabling Custom Error Pages

    As the title sounds, here I’m going to discuss a very simple feature of IIS7 which has one additional step to keep in mind compared to that you do in the previous versions of IIS (5, 5.1, 6). Let’s take an example of configuring a redirect for a page to HTTPS if it is browsed on HTTP. There are a lot of ways doing this HTTP to HTTPS redirection, where using custom error pages is one of them.

  • AppCmd syntax to add FTP IpV4 Address and Domain Restrictions

    I just helped one of my customer writing a script which would add FTP IpV4 Address and Domain Restrictions into the applicationHost.config file. “Configuration Editor” came handy to nail this command. I would say, anybody and everybody wanted to play with AppCmd, and stuck, try your hands on this Configuration Editor which is a part of Administration Pack (still CTP2 at the time of writing) which gives you everything you need – Managed code (C#), Scription (JavaScript) and Command Line (Appcmd) syntax. Below are the commands:

  • IIS – Rejecting a request from a specific client type(browser) | ISAPI Filter Example

    Recently I’ve come across a discussion where a particular type of client request should be blocked. Say for an example, you need to block requests from a client called “TrustMe”; consider a scenario where you need to serve pages only for Internet Explorer 7 clients, not IE6.0 clients. This kind of requests are not so common, but there would be someone who may need this. Hence, this blog post :-)

  • IIS7 – Prevent the server sending its private IP address for a request made by HTTP/1.0 clients with no host header

    Do you remember this problem earlier with IIS sending the server’s private address for a request made for a non host-header site in its headers? You were setting UseHostName or SetHostName property in the metabase to stop the server sending the private IP address. This KB article had the hotfix details, and you need to follow the more information section to be able to stop the server sending.

  • How to configure IIS 7.0 for ODBC logging?

    If you select Log File format as “Custom” in the IIS manager, it doesn’t give you options to configure ODBC logging in the UI. Instead, it just gives you an alert saying it cannot be configured through IIS manager which you already know.

  • ASP.NET - Using the same encryption method used by ActiveDirectoryMembershipProvider to encrypt secret password answer and store it in AD

    Okay, this is an interesting stuff. MembershipProvider automatically encrypts most of the sensitive information such as password, secret-question-password. What if you want to use the same encryption method yourself to encrypt data?

    Before continuing reading, You need to understand and keep in mind that your <machinekey> section is the one which would be used for the encryption / decryption by the MembershipProvider. If you change it after encryption, your decryption may fail. So, please be careful while modifying anything on <machinekey> section in your web.config.

    I've just created a class inheriting from MembershipProvider. I've implemented all the methods of it (just a dummy implementation - VS would be more than happy to do that for you - if you find difficulty in this, write to me; I'll help you). I've also created another new method called EncryptMe which takes a string and returns me a string which is in fact the encrypted string. This method just gets the string in bytes with RNGCryptoServiceProvider and just call the function EncryptPassword of the MembershipProvider class to do the encryption.

    In fact, the EncryptPassword method is a protected method of the MembershipProvider class, and by using it, we have just achieved the same encryption which is used by the MembershipProvider class (which our ActiveDirectoryMembershipProvider also uses to encrypt your secret-password-answer). Since it is protected, you can't access it anywhere outside, but inside a derived class.

    Source of my EncryptMe Function
        public string EncryptMe(string s)
        {
            byte[] bytes = System.Text.Encoding.Unicode.GetBytes(s);
            byte[] data = new byte[0x10];
            new System.Security.Cryptography.RNGCryptoServiceProvider().GetBytes(data);
            byte[] dst = new byte[data.Length + bytes.Length];
            Buffer.BlockCopy(data, 0, dst, 0, data.Length);
            Buffer.BlockCopy(bytes, 0, dst, data.Length, bytes.Length);
            byte[] b = EncryptPassword(dst);
            return Convert.ToBase64String(b);
        }

    Now, you can just store the encrypted string to the active directory property which you've mapped to the Secret-question-password. Check this knowledge base article which explains how to modify an attribute of an user in active directory. It just talks about the properties needed by the FTP user isolation, just modify the code to use your own attribute.

  • ASP.NET - Enabling PasswordReset functionality when using ActiveDirectoryMembershipProvider

    If you want to use ActiveDirectoryMembershipProvider on your website to manage users specially the password reset functionality, you will also need to create few attributes in the active directory schema for the "USER" object. You can check this MSDN article to know more about this, but again, it doesn't list how to create the needed attributes, but it tells you what are all the attributes needed if you are considering "Password Reset" functionality.

  • IIS7 - Configure Throttling for your documents (any MIME type) and save Bandwidth costs

    Do you have a high traffic site where you have a lot of WMV/AVI/FLV/PDF documents (or any other MIME type) where your maximum bandwidth of the site is utilized? Do you ever think where majority of the bandwidth would go? Most of the users do not completely watch the video or listen to audio, or do not read the complete PDF file (or any progressive download document). Assume that they just watch for 5 minutes of your 1 hour long Flash Video (.flv). How much of your bandwidth (for download) would be used for this? You should try answering this question yourself.

  • IIS7 - Kernel Mode Authentication

    One of my customer was running into a kerberos issue on IIS 7.0. While working on this issue, I remembered this kernel-mode windows authentication which would make your kerberos life easier if you are using domain user to run your AppPool as. I was trying to look out to enable kernel mode windows authentication (which is in fact would be enabled by default if the feature is available). But I was not able to find it.

  • Who am I?

    I thought of getting myself involved in the growing IIS community and hence this blog. I work as a Support Engineer in Microsoft Product Support group which supports developers, administrators worldwide on their issues on IIS and ASP.NET. Recently, I started supporting IIS7 which is available on Vista and also on Windows Server 2008. I would use this blog to post articles, tips, how to's specifically on IIS related technologies. You can also follow my MSDN blog here.