Welcome to MSDN Blogs Sign in | Join | Help

.NET Version Detector 2009 to check the installed .NET versions on your system

.NET version detector is a pretty handy tool in detecting the .NET version installed on your system and download the latest .NET version available. The current version of this tool can detect up to framework 4.0. Interestingly the tool also provides link to download SDK, framework and help you to navigate to the installation folder of each framework on your system.

Here is snapshot of the tool when I used it on my machine.

image

You can download this free tool from http://www.asoft.be/prod_netver.html.

Hope this helps!

Sojesh

Posted by sojeshs | 0 Comments
Filed under:

Debug Diag script for troubleshooting .NET 2.0 Memory leaks

Tess has written a nice Debug Diag script for troubleshooting .net memory leaks. Please check out Debug Diag script for troubleshooting .NET 2.0 Memory leaks if you are interested. I have tested this out on my lab and it worked great for me. 

Thanks,

Sojesh

Posted by sojeshs | 0 Comments
Filed under:

Simple application to modify wiki list field title

This post is based on a requirement that came up couple of weeks back. The objective was to modify the default fields title to something different for a wiki page as per the business needs. Interestingly, we had multiple fields to be modified for the wiki list in this scenario and I thought of achieving this through a simple console application which accept some user inputs.

Here is the code(C#) which will accept the wiki site URL, old field title and the new field title for the wiki list. Once the code is executed, the wiki list field title will be modified to the new field title you entered for the specific wiki site.

 
using System;
using System.Collections.Generic;
using Microsoft.SharePoint;
 
namespace Wiki
{
    class Wiki
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Key in your Wiki Site URL and Press Enter:");
            String URL = Console.ReadLine();
 
            Console.WriteLine("Key in the old field name which you want to modify:");
            String oldFieldTitle = Console.ReadLine().ToLowerInvariant();
 
            Console.WriteLine("Key in the new field name:");
            String newFieldTitle = Console.ReadLine();
 
            using (SPSite site = new SPSite(URL))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    SPList myWikiList = web.Lists["Wiki Pages"];
                    SPFieldCollection myWikiFields = myWikiList.Fields;
 
                    foreach (SPField field in myWikiFields)
                    {
                        if (field.Title.ToLowerInvariant().Equals(oldFieldTitle))
                        {
                            field.Title = newFieldTitle;
                            field.Update();
                            Console.WriteLine("Updated the field title to" + newFieldTitle);
                            break;
                        }
                       
                    }
                }
            }
 
        }
    }
}

 

You can create a new console application and just copy the above code in the main class file. Execute the application on the server where you have MOSS installed. 

Hope that helps!

Sojesh

Posted by sojeshs | 1 Comments

HTTP to HTTPS redirection using ASP.NET HTTP Module

I have been very quiet from last couple of months after moving in to SharePoint space. Let me start with a simple  ASP.NET module which I wrote sometime back for HTTP to HTTPS redirection. Recently, I have seen many requests coming with this requirement from developers who has very little control over the web server in a web hosting scenario. They don't want to depend on the web administrator to achieve the simple tasks like redirection from HTTP to HTTPS after hosting their web application (i.e  assuming SSL is configured correctly by the administrator).

Here is a simple HTTP module to achieve the HTTP to HTTPS redirection. The module has registered to listen for one event called context_BeginRequest which does the trick when the first request begins.

using System;
using System.Collections.Generic;
using System.Web;
 
public class Redirect : IHttpModule
{
 
    public Redirect() {}
    #region IHttpModule Members
    public void Dispose()
    {
        throw new NotImplementedException();
    }
 
    public void Init(HttpApplication context)
    {
       context.BeginRequest += new EventHandler(context_BeginRequest);
    }
 
    void context_BeginRequest(object sender, EventArgs e)
    {
        HttpApplication AppObject = (HttpApplication)sender;
 
        if (!AppObject.Request.IsSecureConnection)
        {
            // send user to SSL 
            string serverName = HttpUtility.UrlEncode(AppObject.Request.ServerVariables["SERVER_NAME"]);
            string filePath = AppObject.Request.FilePath;
            AppObject.Response.Redirect("https://" + serverName + filePath);
        }
    }
    #endregion
}

 

You can copy the above code in to class file and save the file as “Redirect.cs”. We can plug this module to ASP.NET pipeline through the application configuration file as shown below. With ASP.NET 2.0, we dont even need to worry about compiling the class in to a DLL. All we need to is put this class file under App_Code (If you don't have one, please create the folder by name “App_Code”) directory of the application root folder. In ASP.NET 2.0 everything under App_Code directory will be compiled in to a single DLL.

 

 <httpModules>
      <clear />
      <add name="Redirect" type="Redirect"/>
      <add name="SPRequest" type="Microsoft.SharePoint.ApplicationRuntime.SPRequestModule, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
      <add name="OutputCache" type="System.Web.Caching.OutputCacheModule" />
      <add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" />
      <add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule" />
      <add name="WindowsAuthentication" type="System.Web.Security.WindowsAuthenticationModule" />
      <add name="RoleManager" type="System.Web.Security.RoleManagerModule" />
      <add name="PublishingHttpModule" type="Microsoft.SharePoint.Publishing.PublishingHttpModule, Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
 </httpModules>

 

As shown below, you need uncheck the “require SSL” option under SSL Setting for that web application to allow HTTP traffic and for the code to work as expected.

image 

 

Hope that helps!

Sojesh

Posted by sojeshs | 2 Comments
Filed under:

Excel Services in MOSS 2007

Introduction

Excel Services are one of the cool features that we have in SharePoint Server 2007. This feature is not available with SharePoint Services 3.0. So that means you will not be able to play around with this feature with a free download of services 3.0 and you will have to spend some dollars.

Well, there are few key requirements for using Excel Services feature even in MOSS 2007.

1. You need to have at least one Shared Service Provider (SSP). This is created by default in a Basic installation of MOSS 2007.

2. Only Office Excel 2007 file formats can be rendered using SharePoint Excel Service. This is due the XML format differences between these files.

How do we set up Excel Services in MOSS 2007?

Lets look at the steps to enable Excel Services in MOSS 2007

  • Open up SharePoint Server Administration and ensure that you have at least on Shared Service Provider created under Shared Server Administration. If you have a server farm installation, you will have to create this manually.

image 

  • Navigate to the Shared Service Provider (E.G.SharedServices1) to bring up the Excel Service Settings.

image

  • Click on Trusted file locations to add a new trusted file location of our web site. Enter the top-level site URL and check Trust Children option to ensure all the child web sites locations are also trusted.

image 

  • Once you are done with adding trusted file location for the web site, lets go to the web site and add a new excel 2007 file in to a document library or you are free to use an existing one as well.
  • Now let’s add an Excel Web Access web part for including the Excel Workbook as shown below.

image 

  • Find the workbook from your document library and add the same in to the workbook.

image

  • The excel workbook will be displayed with in the web part if the file is a supported format. You can define the number of rows and columns that needs to be displayed under the excel workbook

image 

 
Why my file is not getting rendered in my web part?
  • Let me mention what you will receive when the web site location is not added under the trusted location or the file is not a supported format. The custom error messages thrown by SharePoint will clearly explain the end user why excel service could not render the file.

We get the following custom error message when the workbook/file is in unsupported format.

image

We get the following custom error message if you have not added your web site as part of trusted file location.

image

Summary

If you are clear with the steps mentioned above you should be able to setup excel services in MOSS 2007. Again following are the key points to remember

  1. You need to have at least one Shared Service Provider (SSP). This is created by default in a Basic installation of MOSS 2007.
  2. Only Office Excel 2007 file formats can be rendered using SharePoint Excel Service. This is due the XML format differences between these files.
Posted by sojeshs | 1 Comments
Filed under:

SharePoint and MOSS 2007 Series

Taking the focus away from IIS/ASP.NET a little bit, in the last couple of months, I have been doing some reading and implementations on Microsoft SharePoint Technologies. It was a little difficult to get started with a totally new application framework, when I have lot more to do on ASP.NET/IIS. The purpose of this blog is to share my understanding of SharePoint Technologies as an when I learn. Since I haven’t gone so far in understanding these technologies, as part of this exercise, I would also want to ensure this is a good series for any beginner. Let’s get started with a brief introduction!

Introduction

Defining what exactly is SharePoint, was one of the most difficult part during my initial stage of understanding SharePoint Technologies. So let’s make sure we are pretty much clear as what is SharePoint. These are few questions that can come on top of your head while trying to answer this question.

1) Is it just a web application?

2) Is it a technology that helps us to manage web site?

3) Is it an application framework?

Let’s try to answer what SharePoint really is?

“SharePoint is simply an application framework with set of functionality built out of the box. So when you compare ASP.NET and SharePoint, both of them provide a framework for developers to build up on, ASP.NET being at very low-level. So with the default installation of SharePoint, you get many built in features and tools to build up on new features. So keep in mind that if you just do a default installation of SharePoint and use out of the box features, you are not completely utilizing the power of SharePoint as a framework”

SharePoint Server 2007 clears all our doubts in defining SharePoint (i.e. SharePoint Service 3.0) as a complete application framework by adding many comprehensive features out of the box. Now let’s take a look at SharePoint Services vs SharePoint Server 2007.

SharePoint Services vs SharePoint Server 2007

In simple words, SharePoint Server 2007 is a superset of SharePoint Services 3.0. The core of everything is SharePoint Services 3.0 and SharePoint Server 2007 comes with many additional features and toys. I would like start explaining this with a simple drawing.

image 

Other key thing to note is SharePoint Services 3.0 is available as a free download and making a choice between SharePoint Service 3.0 and SharePoint Server 2007 is totally based on what features you want to leverage in your implementation.

If you are interested in knowing about all the new features in MOSS 2007, please refer to http://dotnetaddict.dotnetdevelopersjournal.com/moss_vs_wss.htm

How do I know SharePoint is a solution for my Organization?

Well, the easiest and may be stupid:) answer to this question is, be very familiar with all the features that SharePoint offers you. However, a better a way to look at is considering a scenario and realizing how to make life better with SharePoint.

“In my first company, the total number of employees was about 15, handling two or three projects. The way we handled client communications/approvals,  project work and documentation's were totally depended on email, folder hierarchy and word documents. We also had many issues with versioning different project documents available. Can you think of managing this in the same way, when you have plans to increase the head count by 50, 100 or even more?”

Now let’s see, how SharePoint can play a role here and  improve some these activities.

image

You can clearly see how SharePoint features making each of this task/activity a lot easier.

Key Components of SharePoint Framework

Now that you have a basic understanding of SharePoint, let’s dig in a little more and understand the key components of a SharePoint Framework. Again, let’s start this with a simple drawing to understand this better

image

Web Application is the underlying framework of the SharePoint Site. It’s a collection of ASP scripts and HTML.

Site Collection can be considered as box which contains many individual sites. So in the above diagram you can see three individual sites (Website1, Website2 and Website3) in the site collection.

SharePoint Control Panel or Central Administration allows us to manage Web application, Site Collection and Individual Sites.

Database (Either a dedicated SQL Server or Internal Windows Database) stores all the data related to web applications. Each web application will have a separate database.

I will explain more about each of these components in the upcoming blogs. In the next blog we will take a look at the complete installation procedure of SharePoint Services and SharePoint Server 2007.

Posted by sojeshs | 1 Comments
Filed under:

IIS Case Study: Why my ISAPI filters are not getting loaded?

Last week I was working on an interesting case related to ISAPI filters not getting loaded. The complete description of the problem went like this

“I have an ISAPI filter at the web sites level that intercept the requests and authenticates users (using a similar implementation of forms authentication) before serving the protected asp.net web page. This ISAPI filter also implements the single sign on feature for various web other web applications. When we use a custom identity for application pool the ISAPI filter is not invoked and the users were able to access the protected web pages with out any authentication. To work around this, we need to add the custom identity user for application pool to local administrators group.”

Reading through the problem description, these are the questions to be answered

  1. Why the ISAPI filter is not invoked when we use a custom identity for application pool?
  2. Why the application pool identity needs to be part of local admin group to invoke the ISAPI filter?
  3. Why the ISAPI filter is invoked when the application pool identity is NETWORK SERVICE even though it is not part of Administrators group?

I would like to describe the root cause of the problem by reproducing the same behavior rather than explaining the complete troubleshooting steps.

To start with, we need to download the metabase explorer from http://support.microsoft.com/kb/840671. By default when you launch metabase explorer, it loads the local machines IIS metabase configurations by default. We are interested in the required permissions for the “Filters” node and the default permission list is shown in the below in Figure 1.

Figure1

For this demo purpose, lets consider ASP.NET 2.0 ISAPI filter as an example as shown below in Figure 2.

Figure 2

Now let’s enable ETW (Enterprise Tracing for Windows) tracing and see what we get in the trace. Make sure the application pool identity is NETWORK SERVICE before you enable the tracing. We can enable ETW tracing as explained below.

1) Create a provider file by name providers.guid with following entry

{3a2a4e84-4c21-4981-ae10-3fda0d9b0f83} 0xFFFFFFFE 5 IIS: WWW Server

2) Open up the command prompt and enable ETW Tracing using the following command

“logman start iistrace_etl –pf providers.guid –ets” (without the quotes) and press Enter.

If the worker process is active and the ISAPI filters are loaded you will get the output in the command prompt indicating that providers were activated.

3) Browse any of the .ASPX web pages to reproduce the behavior.

Once you finish, type “logman stop iistrace_etl -ets” (without the quotes) to stop tracing Now generate the report using tracerpt utility or log parser sample scripts “tracerpt iis_trace.etl”

4) Once the trace report is generated you will see all the ISAPI filter events as shown below for each ISAPI Filter

+-------------------------------------------------------------------------------------+
|Event Count Event Name Event Type Guid |
+-------------------------------------------------------------------------------------+
| 3 IISFilter FILTER_PREPROC_HEADERS_END {00237f0d-73eb-4bcf-a232-126693595847}|
| 3 IISFilter FILTER_PREPROC_HEADERS_START {00237f0d-73eb-4bcf-a232-126693595847}|
| 3 IISFilter FILTER_URL_MAP_END {00237f0d-73eb-4bcf-a232-126693595847}|
| 6 IISFilter FILTER_START {00237f0d-73eb-4bcf-a232-126693595847}|
| 6 IISFilter FILTER_END {00237f0d-73eb-4bcf-a232-126693595847}|
| 3 IISFilter FILTER_URL_MAP_START {00237f0d-73eb-4bcf-a232-126693595847}|
| 3 IISFilter FILTER_SET_REQ_HEADER {00237f0d-73eb-4bcf-a232-126693595847}|

Now let’s talk about the changes to break this.

Firstly, we will modify the default permissions set from “Filters” node as shown below. Remove IIS_WPG group from default permission list. See that we no more have the IIS_WPG group under the permissions in Figure 3.

Figure 3

Create a new user and configure that user as the custom identity for the application pool. Make sure to add the new user under IIS_WPG group.

We are ready for the next ETW tracing. Follow the same steps mentioned in the previous section to generate the ETW tracing and report. If you examine the differences in the new ETW trace, you will see that none of the ISAPI filter events are logged.

Now let’s try to answer the questions that we asked at the beginning

  • Why the ISAPI filter is not invoked when we use a custom identity for application pool?

As you can see the custom identity is part of IIS_WPG group and this group does not belongs to the permission set for “Filters” node. So we need to have the IIS_WPG group for filters node since we are using a custom identity and the user is part of IIS_WPG group.

  • Why the ISAPI filter gets invoked when the application pool identity is part of local admin group?

As shown in Figure 3 the “Administrators” group is part of the default permission list. So when ever you add the custom identity to local admin group the process identity gets the required privileges to invoke the ISAPI filter.

  • Why the ISAPI filter is invoked when the application pool identity is NETWORK SERVICE even though it is not part of Administrators group?

Again, as shown in Figure 3 the “NETWORK SERVICE” is explicitly added as part of the default permission list. So the ISAPI filter still gets invoked even though the NETWORK SERVICE is not part of the local administrators group or IIS_WPG group.

Last but not least, I was not able to see any thing in the process monitor even though the root cause of the problem ended up being a permission related issue.

Hope this was useful!

Posted by sojeshs | 2 Comments
Filed under:

About myself and my blog

 

 

The first post in to my blog! Thank you for your interest and time in reading my blog!

 

The intent of this blog entry is to give you an idea about my blog and myself.

 

My main objective behind starting this blog is to keep sharing what ever I learn. I always believe in KISS principle (Keep it simple stupid) and I want to follow the same principle for my blog as well. This is just a start for me and I welcome all of your comments, feedback and questions.

   

I am a developer support engineer on ASP.NET/IIS at Microsoft. So my main focus would be on IIS / ASP.NET along with some of my interesting areas like DBMS and troubleshooting tools.

 

Thanks again and happy reading!

 

 

Posted by sojeshs | 4 Comments
Filed under:
 
Page view tracker