Backup-SPSite http://SP –Path C:\Backup\siteCollection.bak
Restore-SPSite http://SP –Path C:\Backup\siteCollection.bak
Friday, July 1, 2011
Tuesday, June 28, 2011
Use SharePoint BLOB Caching to increase performance
BLOB caching, or disk-based caching, is an out of the box (OOTB) caching mechanism that is built into the MOSS 2007 and SharePoint Server 2010 platforms. It is commonly used to speed-up access to large and relatively static resources that are stored in content databases, such as images, videos, javascript files, and more. Performance improvements are gained by storing these assets on web front-ends (WFEs) once they’ve been requested by a client. This allows SharePoint to serve subsequent requests for such assets directly from WFEs instead of round-tripping to the content database each time a request for such an asset is received. For most SharePoint sites, this type of caching can significantly lighten the load on your SQL Servers and back-end network.
BLOB Caching is controlled through the web.config file for each of the IIS web sites that is associated with a Web application, and it is not enabled by default. Enabling BLOB caching is as simple as setting the enabled attribute to true in the web.config element as shown below.
<BlobCache location=”C:\blobCache” path=”\.(gif|jpg|png|css|js)$” maxSize=”10” enabled=”true” />
BLOB Caching is controlled through the web.config file for each of the IIS web sites that is associated with a Web application, and it is not enabled by default. Enabling BLOB caching is as simple as setting the enabled attribute to true in the web.config element as shown below.
<BlobCache location=”C:\blobCache” path=”\.(gif|jpg|png|css|js)$” maxSize=”10” enabled=”true” />
Thursday, June 23, 2011
SharePoint FxCop Rules
http://sovfxcoprules.codeplex.com/
SP0001 - Dispose created SPSite or SPWeb objects
SP0002 - Dispose SPWeb returned from a method
SP0003 - Do not dispose SPSite.RootWeb and SPWeb.ParentWeb properties
SP0004 - Dispose SPSite returned from the SPSiteCollection.Add method
SP0005 - Dispose SPSite returned from the SPSiteCollection index operator
SP0006 - Dispose SPWeb returned from the SPSite.AllWebs.Add method
SP0007 - Dispose SPWeb returned from the SPSite.AllWebs index operator
SP0009 - Dispose SPWeb returned from the SPWeb.Webs.Add method
SP0010 - Dispose SPWeb returned from the SPWeb.Webs index operator
SP0011 - Dispose SPWeb returned from the Area.Web property
SP0012 - Dispose the SPLimitedWebPartManager.Web property
SP0013 - Do not dispose SPList.ParentWeb when using the SPList.BreakRoleInheritance method
SP0014 - Close PublishingWeb returned from the PublishingWeb.GetPublishingWebs index operator
SP0015 - Do not dispose SPSite and SPWeb returned from the GetContextSite and GetContextWeb methods
SP0017 - Do not dispose SPSite and SPWeb returned from the SPFeature.Parent property
SP0018 - Close PublishingWeb returned from the PublishingWeb.GetVariation method
SP0019 - Dispose SPSite returned from the UserProfiles.PersonalSite property
SP0008 - Do not dispose SPSite.RootWeb when using SPSite.LockIssue, SPSite.Owner or SPSite.SecondaryContact properties
SP0016 - Do not dispose SPSite and SPWeb returned from the SPContext.Current.Site, SPContext.Site, SPContext.Current.Web and SPContext.Web properties
SP0001 - Dispose created SPSite or SPWeb objects
SP0002 - Dispose SPWeb returned from a method
SP0003 - Do not dispose SPSite.RootWeb and SPWeb.ParentWeb properties
SP0004 - Dispose SPSite returned from the SPSiteCollection.Add method
SP0005 - Dispose SPSite returned from the SPSiteCollection index operator
SP0006 - Dispose SPWeb returned from the SPSite.AllWebs.Add method
SP0007 - Dispose SPWeb returned from the SPSite.AllWebs index operator
SP0009 - Dispose SPWeb returned from the SPWeb.Webs.Add method
SP0010 - Dispose SPWeb returned from the SPWeb.Webs index operator
SP0011 - Dispose SPWeb returned from the Area.Web property
SP0012 - Dispose the SPLimitedWebPartManager.Web property
SP0013 - Do not dispose SPList.ParentWeb when using the SPList.BreakRoleInheritance method
SP0014 - Close PublishingWeb returned from the PublishingWeb.GetPublishingWebs index operator
SP0015 - Do not dispose SPSite and SPWeb returned from the GetContextSite and GetContextWeb methods
SP0017 - Do not dispose SPSite and SPWeb returned from the SPFeature.Parent property
SP0018 - Close PublishingWeb returned from the PublishingWeb.GetVariation method
SP0019 - Dispose SPSite returned from the UserProfiles.PersonalSite property
SP0008 - Do not dispose SPSite.RootWeb when using SPSite.LockIssue, SPSite.Owner or SPSite.SecondaryContact properties
SP0016 - Do not dispose SPSite and SPWeb returned from the SPContext.Current.Site, SPContext.Site, SPContext.Current.Web and SPContext.Web properties
Adding List Items using PowerShell
SharePoint 2010 offers over 500 new cmdlets that we can use to automate the SharePoint 2010 environment through Windows PowerShell. The cmdlets go as deep as SPWeb, everything beyond SPWeb requires additional scripting, such as adding fields, views and items. Here’s an example showing how to add an item to the Announcements list in SharePoint 2010:
$spWeb = Get-SPWeb -identity http://SP
$spList = $spWeb.GetList(“Lists/Announcements")
$newItem = $spList.AddItem()
$newItem["Title"] = "My First Announcement"
$newItem["Body"] = "
$newItem["Expires"] = "5/5/2010"
$newItem.Update()
$spWeb.Dispose()
In the example we use the Get-SPWeb cmdlet to bind to a specific site. Next we use the GetList() method to retrieve a list. The method accepts a lists relative URL as input. We then use the AddItem() method to create a new item in SharePoint 2010. Finally we use the Dispose() method on the SPWeb object to make sure that the object is disposed of correctly.
$spWeb = Get-SPWeb -identity http://SP
$spList = $spWeb.GetList(“Lists/Announcements")
$newItem = $spList.AddItem()
$newItem["Title"] = "My First Announcement"
$newItem["Body"] = "
PowerShell Magic
"$newItem["Expires"] = "5/5/2010"
$newItem.Update()
$spWeb.Dispose()
In the example we use the Get-SPWeb cmdlet to bind to a specific site. Next we use the GetList() method to retrieve a list. The method accepts a lists relative URL as input. We then use the AddItem() method to create a new item in SharePoint 2010. Finally we use the Dispose() method on the SPWeb object to make sure that the object is disposed of correctly.
PowerShell commands for SharePoint 2010
>Get-Command -Noun SPSite
You can get the all PowerShell commands:
>Get-Help Get-SPSite
You can get the Name, Syntax, Description, Related Links, Remarks
To Retrieve content database for a specific site collection:
>Get-SPContentDatabase -Site http://SPServer01
Results:
ID :96dfa345-43df-3edg-bbc6-1l4e8ee105le
Name :WSS_content
Web Application :SPWeb Application Name=Sharepoint - 80
Server :SPServer01
CurrentSiteCount :2
To retrieve the content database for a specific Web Application:
>Get-SPContentDatabase -WebApplication "Sharepoint - 80"
Results:
ID :96dfa345-43df-3edg-bbc6-1l4e8ee105le
Name :WSS_content
Web Application :SPWeb Application Name=Sharepoint - 80
Server :SPServer01
CurrentSiteCount :2
You can get the all PowerShell commands:
>Get-Help Get-SPSite
You can get the Name, Syntax, Description, Related Links, Remarks
To Retrieve content database for a specific site collection:
>Get-SPContentDatabase -Site http://SPServer01
Results:
ID :96dfa345-43df-3edg-bbc6-1l4e8ee105le
Name :WSS_content
Web Application :SPWeb Application Name=Sharepoint - 80
Server :SPServer01
CurrentSiteCount :2
To retrieve the content database for a specific Web Application:
>Get-SPContentDatabase -WebApplication "Sharepoint - 80"
Results:
ID :96dfa345-43df-3edg-bbc6-1l4e8ee105le
Name :WSS_content
Web Application :SPWeb Application Name=Sharepoint - 80
Server :SPServer01
CurrentSiteCount :2
Developer Dashboard in SharePoint 2010
DD will obviously not give you all answers you need to solve performance/page load issues (for instance you might have to talk to your SQL guru to optimize T-SQL queries or C# developer to optimize their webpart algorithm or tell your end user that they have put too many webparts on a page). In the end it will make the life of any user and a lot easier to understand page load in SharePoint 2010 and hence Project Server 2010.
Script to turn on/off DD (not do not turn it ON in your production server since it will activate it for all pages for all users in your farm!) (copy and paste in a file and save with .BAT extension then execute in your farm):
echo off
@SET UTILS_ROOT=C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN
@echo ENABLE Developer Dashboard
@echo ================================================================
"%UTILS_ROOT%\stsadm" -o setproperty -pn developer-dashboard -pv ondemand
@echo DISABLE Developer Dashboard
@echo ================================================================
REM "%UTILS_ROOT%\stsadm" -o setproperty -pn developer-dashboard -pv off
PAUSE
Script to turn on/off DD (not do not turn it ON in your production server since it will activate it for all pages for all users in your farm!) (copy and paste in a file and save with .BAT extension then execute in your farm):
echo off
@SET UTILS_ROOT=C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN
@echo ENABLE Developer Dashboard
@echo ================================================================
"%UTILS_ROOT%\stsadm" -o setproperty -pn developer-dashboard -pv ondemand
@echo DISABLE Developer Dashboard
@echo ================================================================
REM "%UTILS_ROOT%\stsadm" -o setproperty -pn developer-dashboard -pv off
PAUSE
Wednesday, June 22, 2011
AJAX References
http://www.msjoe.com/videos/microsoft-ajax/
<contenttemplate> ...some controls here...> </contenttemplate>
<triggers>
<asyncpostbacktrigger controlid="control to listen to" eventname="click">
</asyncpostbacktrigger>
</triggers>
ASP.NET Notes
- ASP.NET 2.0 Ajax Extensions 1.0
- Installed under C:\Program Files\Microsoft ASP.NET
- In Visual Studio, create an ASP.NET AJAX Enabled Website (from a template)
- Every page has an instance of the ScriptManager
- Partial Page Update Pattern
- UpdatePanel Control - server side control that enables us to place fires an event for the server to update the contents of the panel
<contenttemplate> ...some controls here...> </contenttemplate>
<triggers>
<asyncpostbacktrigger controlid="control to listen to" eventname="click">
</asyncpostbacktrigger>
</triggers>
ASP.NET Notes
- Date.Now
JQuery Resources
JQuery QuickSearch Plugin
http://www.msjoe.com/2011/06/filtering-an-asp-net-gridview-control-with-jquery/
Other Articles
http://www.msjoe.com/category/jquery/
http://www.msjoe.com/2011/06/filtering-an-asp-net-gridview-control-with-jquery/
Other Articles
http://www.msjoe.com/category/jquery/
Wednesday, June 1, 2011
Saturday, May 28, 2011
Use Cascading Style Sheets for Web Page Layout?
- Table-Based Approach
- DIV Approach
ASP.NET Localization
- Resource File particular to a page such as Default.aspx.resx within App_LocalResources
- Label1.Text = "Hello"
- Another Resource File Default.aspx.fr.resx (French)
- Label1.Text = "Bonjour"
- control property meta:resourceKey="Button1"
- page declaration Culture="auto:en-US" UICulture="auto"
- Internet Options : New Languages
- App_GlobalResources
- Properties > Expression then indicate ClassKey and ResourceKey
- System.Threading
- System.Globalization
Friday, May 20, 2011
ASP.NET Interview Questions
- What is an interface and what is an abstract class? Please, expand by examples of using both. Explain why.
- What is serialization, how it works in .NET?
- What should one do to make class serializable?
- What exactly is being serialized when you perform serialization?
- Tell me about the methods you have used to perform serialization.
- Did you work with XML and XSL Transformations?
- What methods and what for did you use to work with XML?
- What is the purpose of reserved word “using” in C#?
- How does output caching work in ASP.NET?
- What is connection pooling and how do you make your application use it?
- What are different methods of session maintenance in ASP.NET?
- What is Viewstate?
- Can any object be stored in a Viewstate?
- What should you do to store an object in a Viewstate?
- Explain how Viewstate is being formed and how it’s stored on client.
- Explain control life cycle, mind event order.
- What do you know about ADO.NET’s objects and methods?
- Explain DataSet.AcceptChanges and DataAdapter.Update methods.
- Assume you want to update a record in the database using ADO.NET. What necessary steps you should perform to accomplish this?
- How to retreive the value of last identity has been updated in a database (SQL Server)?
.NET Classes and Namespaces
StringWriter
HTMLTextWriter
System.Collections
System.Security
System.Configuration
HTMLTextWriter
System.Collections
System.Security
System.Configuration
Tuesday, March 22, 2011
LINQ to SQL Sample
DataClassesDataContext dataContext = new DataClassesDataContext();
DataTable dtEmployees = new DataTable();
var employees = from empTable in dataContext.Employees
select empTable;
foreach (Employee empRecord in employees)
{
Response.Write(empRecord.LoginID + "
");
}
dtEmployees = (DataTable)employees;
dgEmployeesList.DataSource = dtEmployees;
dgEmployeesList.DataBind();
DataTable dtEmployees = new DataTable();
var employees = from empTable in dataContext.Employees
select empTable;
foreach (Employee empRecord in employees)
{
Response.Write(empRecord.LoginID + "
");
}
dtEmployees = (DataTable)employees;
dgEmployeesList.DataSource = dtEmployees;
dgEmployeesList.DataBind();
Stored Procedure Sample
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [HumanResources].[uspUpdateEmployeeHireInfo]
@EmployeeID [int],
@Title [nvarchar](50),
@HireDate [datetime],
@RateChangeDate [datetime],
@Rate [money],
@PayFrequency [tinyint],
@CurrentFlag [dbo].[Flag]
WITH EXECUTE AS CALLER
AS
BEGIN
SET NOCOUNT ON;
BEGIN TRY
BEGIN TRANSACTION;
UPDATE [HumanResources].[Employee]
SET [Title] = @Title
,[HireDate] = @HireDate
,[CurrentFlag] = @CurrentFlag
WHERE [EmployeeID] = @EmployeeID;
INSERT INTO [HumanResources].[EmployeePayHistory]
([EmployeeID]
,[RateChangeDate]
,[Rate]
,[PayFrequency])
VALUES (@EmployeeID, @RateChangeDate, @Rate, @PayFrequency);
COMMIT TRANSACTION;
END TRY
BEGIN CATCH
-- Rollback any active or uncommittable transactions before
-- inserting information in the ErrorLog
IF @@TRANCOUNT > 0
BEGIN
ROLLBACK TRANSACTION;
END
EXECUTE [dbo].[uspLogError];
END CATCH;
END;
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [HumanResources].[uspUpdateEmployeeHireInfo]
@EmployeeID [int],
@Title [nvarchar](50),
@HireDate [datetime],
@RateChangeDate [datetime],
@Rate [money],
@PayFrequency [tinyint],
@CurrentFlag [dbo].[Flag]
WITH EXECUTE AS CALLER
AS
BEGIN
SET NOCOUNT ON;
BEGIN TRY
BEGIN TRANSACTION;
UPDATE [HumanResources].[Employee]
SET [Title] = @Title
,[HireDate] = @HireDate
,[CurrentFlag] = @CurrentFlag
WHERE [EmployeeID] = @EmployeeID;
INSERT INTO [HumanResources].[EmployeePayHistory]
([EmployeeID]
,[RateChangeDate]
,[Rate]
,[PayFrequency])
VALUES (@EmployeeID, @RateChangeDate, @Rate, @PayFrequency);
COMMIT TRANSACTION;
END TRY
BEGIN CATCH
-- Rollback any active or uncommittable transactions before
-- inserting information in the ErrorLog
IF @@TRANCOUNT > 0
BEGIN
ROLLBACK TRANSACTION;
END
EXECUTE [dbo].[uspLogError];
END CATCH;
END;
Subscribe to:
Posts (Atom)