Tuesday, June 30, 2015

Uploading Large Files to SharePoint



  1. Increase the Maximum Upload Size for the Web Application from Central Administration site
    • Browse to Central Administration site and click on Application Management
    • Click on 'Web Application General Settings' under 'SharePoint Web Application Management ' and choose the appropriate web application
    • Modify the value for 'Maximum Upload Size' property to specify the maximum size which is allowed for a single upload to any site under the web application.
      Note: You can choose multiple files and folders to be uploaded provided no single file or the collective size goes beyond 2 GB
    • A value of '1000' would set the max upload size to 1 GB. The maximum upload size cannot be increased beyond '2000' (2 Gb)
    • The default file size for upload is 50 Mb in IIS 6.0) and 28 Mb for IIS 7.0.

  1. Increase the connection time-out setting in IIS

    By default, the IIS connection time-out setting is 120 seconds (2 minutes). Follow these steps to increase the connection time-out setting:
    • In IIS manager, expand the 'Sites' node and select the SharePoint site
    • Click 'Advanced Settings' from the actions pane OR right-click the SharePoint site, Manage Web site and click 'Advanced Settings'
    • Increase the 'Connection time-out' value (seconds); under 'Connection limits' from the 'Advanced Settings' dialog box to avoid IIS time-outs when large files are being uploaded
    • You can specify the time-out value based on file size and the time taken for the file to be uploaded
    • You can also select the SharePoint site in IIS and click on the 'Limits' link in the actions pane.  
                     
  2. Increase the maximum upload size in the web.config file of web application

    The maxAllowedContentLength property specifies the maximum length of content in a request in bytes and it needs to be set on a Windows Server 2008 computer that has IIS 7.0-only installations.
To change the value of the property via web.config, do the following:
Open the web.config file of a web application located in %Inetpub%\Wwwroot\Wss\VirtualDirectories\<Virtual Directory> folder and add the following code at the bottom, just before the close out of the <configuration> section of the Web.config file
            <Configuration>
            ..
            ..
            <system.webServer>
                <Security>
                        <RequestFiltering>
                                   <requestLimits maxAllowedContentLength”52428800’/>
                        </requestFiltering>
                </security>
            </system.webServer>
            </configuration>
 This sets the value of the maxAllowedContentLength property to 52428800 (in bytes) for the web application only.
 To change the value of the property via command-line, do the following:   
    • Open command prompt and go to 'C:\windows\system32\inetsrv' directory
    • Run the below command:        

      Appcmd set config /section:requestfiltering /requestlimits.maxallowedcontentlength:unit
             
      Where the variable requestlimits.maxallowedcontentlength unit specifies the maximum length of content (in bytes). For example, to specify 2000000000 as the maximum length of content, type the following at the command prompt, and then press ENTER:

      Appcmd set config /section:requestfiltering /requestlimits.maxallowedcontentlength:2000000000
            

  1. Increase the default chunk size for large files
               
    the large-file-chunk-size property sets the amount of data that can be read from server running SQL Server at one time. Points to remember:            
    • If you have a file that is greater than your chunk size (such as 100 MB when the chunk size is set to 5 MB), the file would be read in 20 chunks (100 / 5).
    • The chunk size is not related to the maximum upload file size.
    • The chunk size simply specifies the amount of data that can be read from a file at one time. By default, the large-file-chunk-size property is set to 5 MB.
    • Be aware that if you set the chunk size too high, the files might use a high amount of memory of the web front-end.
In order to set the large–file–chunk–size property, we need to use the command line. This property is configured at a server or server farm level, and cannot be configured for an individual web application. To set this property, use the following syntax:

Stsadm.exe –o setproperty –pn large–file–chunk–size –pv <size in bytes>
               
  1. Add the ExecutionTimeout Value in the web.config
    • "12\TEMPLATE\LAYOUTS" folder

      Open the 'Web.config' file from the 'C:\Program Files\Common Files\Microsoft Shared\Web server extensions\12\TEMPLATE\LAYOUTS' directory. Add the executionTimeout value that you want. For example, replace the value as follows

      Existing code

      <location path="upload.aspx">
          <system.web>
              <httpRuntime maxRequestLength="2097151" />
          </system.web>
      </location>  

      Replacement Code

      <location path="upload.aspx">
          <system.web>
              <httpRuntime executionTimeout="999999" maxRequestLength="2097151" />
          </system.web>
      </location>  
    • Web App

      Open the web.config file located at 'C:\Inetpub\wwwroot\wss\VirtualDirectories\' folder and modify it as follows
       
      Existing line:             <httpRuntime maxRequestLength="51200" />          
      Replacement line:     <httpRuntime executionTimeout="999999" maxRequestLength="51200" />          
         
    • "12\CONFIG"

      Open the web.config located at "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\CONFIG" and modify the 'maxRequestLength' property which by default should be the following:

       <httpRuntime maxRequestLength="51200"/>  

      Change the value to match the other web.configs          

  1. Save the file and perform an ' IISreset /noforce'.

Thursday, June 18, 2015

Difference between List Definition, List Template and List Instance



List Definition:
A list definition defines a schema for a SharePoint list. It contains information on what views are being used, which columns and content types are being used, and other metadata information.
 
List Template:
A list template can either be created by end users through the SharePoint user interface using an existing list as a pattern or using an existing list instance. If based on a user-created list it is called a custom list template. A custom list template includes everything that defines the list, including list columns and site columns used by the list, content types used by the list, views defined for the list, and so on.
 
Tips
A list template may sound like a list definition but they are effectively the same thing, a pattern for a SharePoint list. They differ mainly in how they are created:
- A list templates are created in SharePoint or SharePoint designer.
- A list definitions in Visual Studio.

List Instance:
A list instance is an instance of a specific SharePoint list definition or list template. All of its data is stored in the relevant content database. Typically a list in SharePoint used by end users to enter and view data and it is based on either a list template or list definition.
References:
Addison Wesley - SharePoint 2010 Development with Visual Studio 2010

SharePoint 2013: ExecuteOrDelayUntilScriptLoaded not executing after page publish



In SharePoint Client Object Model and after migration from SharePoint 2010 to SharePoint 2013 your Client Object Model code is running well when the page is Unpublished but once you Published it your Client Object Model Code is not working, don't worry this is not a bug but Microsoft did some changes in the "ExecuteOrDelayUntilScriptLoaded" method in SharePoint 2013 and renamed it to be "executeFunc"
Example:
SharePoint 2013 Code:
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady);
function sharePointReady() {
   alert("Ready");
}
SharePoint 2010 Code:
ExecuteOrDelayUntilScriptLoaded(sharePointReady, "sp.js");
function sharePointReady() {
   alert("Ready");
References:
http://msdn.microsoft.com/en-us/library/jj245759.aspx

Access Denied on the site collection after migrating form SharePoint 2010 to SharePoint 2013.



Problem:
This problem happens if you are using the detach and attached database approach for the migrating SharePoint 2010 to SharePoint 2013 because the old site collection administrator user is already stored in the content database  
Solution:

1-      If you connected the same domain you will not see this problem otherwise
2-      Open the Central Administration and under the application management
3-      Select "Change Site Collection Administrator" then you will find the old site collection administrator   
4-      Then change the old site collection administrator with the new one