Resolved: Run .swf and other MIME type files in web browser in SharePoint 2010 scnerio

One fine day i migrate a SharePoint portal of a client from MOSS 2007 to SharePoint 2010. Well as usual i face so many problems during migration and after migration. This was the one problem i face after migration. It was interesting so i decide to share this with you guys.
Well there was a training site in MOSS 2007 and this site contains a document library that in addition contains some demo .swf files. Client put a view of this library on training site home page. So whenever any one click on any demo files, this runs on browser. Well after successful migration of this site to SharePoint 2010 i decide to test this site. During testing when i clicked on a .swf demo file then in place of running in browser it asked me to download the file. This was problematic to me as client want this site to run on browser only not to download it and he want exactly what it was behaving in MOSS 2007. I checked for Blocked File Types, Shock-wave plug-in installation on browser, mime type added in IIS. But with no luck as all settings was perfectly fine and on same machine and browser MOSS 2007 training site was perfectly running. I thought about the security issue and permission but i was partially right coz i was the site collection administrator and had the full permission so permission was not the problem. But definitely it was due to security, so i searched for relative security settings and after some research i came to know about the new setting provided in SharePoint 2010 for web applications and it was “Browser File Handling”. Well below are the steps that how i resolved this:
1. Open Central Administration Site.
2. On left hand menu, click on Application Management.
3. In “Web Applications” section, Click on “Manage web applications” link.
4. Select the desired application by clicking on it.
5. Now on the Ribbon menu (Top Menu), Click on General Settings Icon arrow. A pop up will open, in this pop up select General Settings.
6. Another pop up page will open, scroll down the page and go to “Browser File Handling” section.
7. In my case by default it was set to strict. I change this setting to Permissive.
8. Click OK and it was done.

Now i open my SharePoint 2010 training site and clicked on a demo .swf file and voila this time it didn’t ask me to download rather it played on browser as it played in MOSS 2007 site.

Note:
“Browser File Handling”
Specifies whether additional security headers are added to documents served to web browsers. These headers specify that a browser should show a download prompt for certain types of files (for example, .html) and to use the server’s specified MIME type for other types of files.
Permissive Specifies no headers are added, which provides a more compatible user experience.
Strict Adds headers that force the browser to download certain types of files. The forced download improves security for the server by disallowing the automatic execution of Web content that contributors upload.

Advertisements

How to remove/delete SharePoint extended site placed in different zones

Well as we know that we can extend a SharePoint site for different zone other than default with different port number and host header. In extended site creation, a new site creates on IIS pointing to a new virtual directory on server. This new virtual directory has its own web.config file for extended site. But extended site points to same content db as the original site has. Therefore end user access same contents through different site urls depending upon the permission set on individual sites. In short you can say that extended site is a replica of its original site as both sites serve from same content db.

Now you want to remove/delete an extended web site from SharePoint server. What to do as extended site doesn’t show in “web application list” and in “Delete Web application”. Well no probes as I mentioned earlier that when we extend a web application it just create a site in IIS and point to existing site content database. So if we remove it from IIS and delete the virtual directory created by extended site then it should remove and delete from SharePoint server. But that’s a manually part and in this case we can miss some references. So here is the best practice for that:

  • Open Central Administration and go to Application Management tab.
  • Under “SharePoint Web Application Management” section, click on “Remove SharePoint from IIS Web site” link.
  • Select the actual web application from which you create extended site.
  • Under “Select IIS Web site and zone to remove” drop down list, expand the drop down by clicking the arrow button.
  • Here you will get all the extended sites with their zones including the actual website (Always created in Default Zone).
  • Select the extended site that you want to remove.
  • Under “Delete IIS Web sites”, check the Yes radio button and click OK.
  • Wait for processing and after completing the process you are done.

Reset Internet Information Services for SharePoint In Depth

When we create a new web application in SharePoint using central administration, we get a section of Reset Internet Information Services and by default its set to “Restart IIS Manually”. Many times we keep this option by default and create the application but even after successful web application creation we don’t reset IIS and go further for Site Collection creation without any problem. So what is the use of that option even we don’t do anything manually. So here is the explanation.

Single Server Scenario

When we create a new web application it asks for the Application Pool information to us. We can use an Application pool for new web application from the existing application pools or we can create a new application pool for the web application. Now if we create a new application pool then we need not to reset IIS as the purpose of IIS reset is just to recycle the application pool in which our newly created web application will reside. But if we use the existing application pool then it’s the best and recommended practice to reset IIS as may be of existing application pool will not recognize the new web application some time so we need to recycle this using an IIS reset.

Best Practice:

So for the best practices, always go for default option and do an “IISRESET /noforce” manually on application server whenever a new application created in a Single server scenario.

Farm Scenario

Another option i.e. “Restart IIS Automatically” never applies to application server (In which the CA exists) but this option is used to reset the IIS on other web front end servers reside in Farm. For the Application server either it is single server configuration or farm configuration you must reset IIS manually as it won’t reset IIS automatically for application server.

In the Farm scenario, If “Restart IIS Automatically” option is not selected and you have more than one server in the farm, you must wait until the IIS web site is created on all servers, and then run “IISRESET /noforce” on each Web server.  The new IIS site will not be usable until that is completed.

Best Practice:

So for the best practices, always select “Restart IIS Automatically” option and do an “IISRESET /noforce” manually on application server whenever a new application created in a FARM scenario.

Using Command-Line Scripts in IIS 6.0

Using Command-Line Scripts in IIS 6.0

This article describes how to use command-line scripts to perform some common administrative tasks that pertain to the management of Web sites and Web virtual directories in Internet Information Services (IIS) 6.0. It also describes how to use the Iisweb.vbs script to create and delete Web sites, and how to use the Iisvdir.vbs script to create and delete Web virtual directories.

Overview
IIS 6.0 includes several supported command-line scripts that use the Windows Management Instrumentation (WMI) provider to configure and manage IIS metabase configurations on local or remote computers that are running IIS. You can use these scripts to automate tasks, remotely administer sites and resources, and take advantage of batch files to create and manage objects. Microsoft supports the command-line scripts that are included in IIS, assuming that those scripts are not modified. If you want to modify a supported script, save it under a new file name so that the original script remains unmodified.

The scripts are located in the %SystemRoot\System32 folder. You must be a member of the Administrators group on the local computer to run scripts and executables, or you must be delegated the appropriate permissions. To open a command prompt to perform any of the tasks that are described in this article, follow these steps: 1. Click Start, click Run, type cmd in the Open box, and then click OK.
2. Type the following line, and then press ENTER:
cd %systemroot%\system32

To Create and Manage Web Sites
To create and manage Web sites by using the Iisweb.vbs script, use the following methods.

To Create a New Web Site
To create a new Web site configuration, use the iisweb /create command. This command does not create content, but it sets up the folder structure and some IIS configuration files. When you use Iisweb.vbs to create a new Web site, you specify only the basic properties that are required to create the site and identify its contents. To configure more advanced properties, use IIS Manager.

The Iisweb /create command uses the following syntax:
iisweb /create PathSiteName [/b Port] [/i IPAddress] [/d HostHeader] [/dontstart] [/s Computer [/u [Domain\]User /p Password]]
The parameters used by Iisweb /create are described as follows: • Path: Specifies the location of content files for the Web site on the local computer. If the specified path does not exist, Iisweb creates it.
• SiteName: A required parameter that specifies the name of the Web site.
• /b Port: Specifies a TCP port number for the Web site. The default port is 80.
• /i IPAddress: Specifies an IP address for the Web site. The default setting, All Unassigned, assigns to the site all the IP addresses on the computer that are not assigned to other sites.
• /d HostHeader: Specifies the host header name for the Web site. By default, the site does not have a host header name and must be identified by its IP address or port number.
• /dontstart: This parameter specifies that the Web site will not start automatically after it is created.
• /s Computer: Runs the script on the specified remote computer. Type the computer name or IP address without backslashes. By default, the script runs on the local computer.
• /u [Domain\]User: Runs the script with the permissions of the specified user account. This account must be a member of the Administrators group on the remote computer. By default, the script runs with the permissions of the current user of the local computer.
• /p Password: Specifies the password of the user account that is specified in the /u parameter.
The following sample command line creates a Web site configuration named My Site on the local computer. The source files are located in the C:\MySource folder, and the host header name is specified:
iisweb /create C:\MySource “My Site” /d www.mywebsite.com /dontstart

To Delete a Web Site
To delete a Web site configuration, use the iisweb /delete command. This command is useful if you plan to move the site to a new Uniform Resource Locator (URL) or server, or if you want to remove it completely. The content of the site is not affected after you use this command, but the site is inaccessible to users.

The iisweb /delete command uses the following syntax:
iisweb /delete WebSite [WebSite…] [/s Computer [/u [Domain\]User/p Password]]
The parameters used by Iisweb /delete are described as follows: • WebSite: A required parameter that specifies the unique descriptive name or metabase path of the Web site. If more than one Web site uses the same descriptive name, you must use the metabase path to identify the Web site.
• /s Computer: Runs the script on the specified remote computer. Type the computer name or IP address without backslashes. By default, the script runs on the local computer.
• /u [Domain\]User: Runs the script with the permissions of the specified user account. This account must be a member of the Administrators group on the remote computer. By default, the script runs with the permissions of the current user of the local computer.
• /p Password: Specifies the password of the user account that is specified in the /u parameter.
The following sample command line deletes a Web site configuration named My Site on the local computer:
iisweb /delete “My Site”

To List Web Sites
To query or list Web sites, use the iisweb /query command. This command is useful when you want to check the status or check the properties of Web sites on a local or remote computer.

The iisweb /query command uses the following syntax:
iisweb /query WebSite [WebSite…] [/s Computer [/u [Domain\]User /p Password]]
The parameters used by iisweb /query are described as follows: • WebSite: Limits the query to the specified Web site. Use the unique descriptive name or metabase path of the Web site. If you omit this parameter, all Web sites on the computer are included in the display.
• /s Computer: Runs the script on the specified remote computer. Type the computer name or IP address without backslashes. By default, the script runs on the local computer.
• /u [Domain\]User: Runs the script with the permissions of the specified user account. This account must be a member of the Administrators group on the remote computer. By default, the script runs with the permissions of the current user of the local computer.
• /p Password: Specifies the password of the user account that is specified in the /u parameter.
The following sample command line displays the Web sites on the local computer:
iisweb /query

To Create and Manage Web Virtual Directories
To create and manage Web virtual directories by using the iisvdir.vbs script, use the following methods.
To Create a New Web Virtual Directory
To create a new Web virtual directory, use the iisvdir /create command. This command does not create content, but it sets up the virtual directory structure and IIS configuration files. When you use Iisvdir.vbs to create a new Web virtual directory, you specify only the basic properties that are required to create the site and identify its contents. To configure more advanced properties, use IIS Manager.

The iisvdir /create command uses the following syntax:
iisvdir /create WebSite [/Virtual Path]Name Physical Path [/s Computer [/u [Domain\] User /p Password]]
The parameters used by iisvdir /create are described as follows: • WebSite: A required parameter that specifies the unique descriptive name or metabase path of the Web site.
• Virtual Path: Specifies a path to the virtual directory in the Web site. This parameter is required if the virtual directory is not located at the root of the Web site.
• Name : A required parameter that specifies a name for the virtual directory. Virtual directory names do not have to be unique. However, when a Web site includes a virtual directory and a physical directory with the same name, the physical directory is not visible on the Internet.
• Physical Path: Specifies a physical folder where the content for the virtual directory resides on the local computer. If the specified folder does not exist, Iisvdir creates it.
• /s Computer: Runs the script on the specified remote computer. Type the computer name or IP address without backslashes. By default, the script runs on the local computer.
• /u [Domain\]User: Runs the script with the permissions of the specified user account. This account must be a member of the Administrators group on the remote computer. By default, the script runs with the permissions of the current user of the local computer.
• /p Password: Specifies the password of the user account that is specified in the /u parameter.
The following sample command line creates the Projects virtual directory at the root of the “Marketing” Web site on the local computer. It associates the directory with content that is currently stored in the C:\Corp\Projects\Web folder:
iisvdir /create Marketing Projects c:\corp\projects\web

To Delete a Web Virtual Directory
To delete a Web virtual directory, use the iisvdir /delete command.

The iisvdir /delete command uses the following syntax:
iisvdir /delete WebSite [/Virtual Path]Name [/s Computer [/u [Domain\]User /p Password]]
The parameters used by iisvdir /delete are described as follows: • WebSite: A required parameter that specifies the unique descriptive name or metabase path of the Web site.
• Virtual Path: Specifies a path to the virtual directory in the Web site. This parameter is required if the virtual directory is not located at the root of the Web site.
• Name : A required parameter that specifies a name for the virtual directory. Virtual directory names do not have to be unique. However, when a Web site includes a virtual directory and a physical directory with the same name, the physical directory is not visible on the Internet.
• /s Computer: Runs the script on the specified remote computer. Type the computer name or IP address without backslashes. By default, the script runs on the local computer.
• /u [Domain\]User: Runs the script with the permissions of the specified user account. This account must be a member of the Administrators group on the remote computer. By default, the script runs with the permissions of the current user of the local computer.
• /p Password: Specifies the password of the user account that is specified in the /u parameter.
The following sample command line deletes the Projects virtual directory from the “Marketing” Web site on the local computer. Note that all virtual subdirectories of the Projects virtual directory are also deleted.
iisvdir /delete Marketing/Projects