Sunday, July 14, 2013

IIS, Worker Process, Application Pool


What is IIS?
IIS (Internet Information Server) is one of the most powerful web servers from Microsoft Corporation that is used to host the Asp.Net web application. IIS has its own ASP.NET process engine to handle the ASP.NET request. So, when request comes from client to server, IIS takes the request and process it and send response back to the clients.
IIS means when request comes from client to the server a lot of operation is performed before sending response to the client. This is about how IIS process the request.
What is Worker Process?
Worker process (w3wp.exe) runs the ASP.NET application in IIS. This process is responsible to manage all the request and response that are coming from the client system. All the ASP.NET functionality runs under the scope of worker process. When request comes to the server from a client worker process is responsible to generate the request and response.
In single word, we can say worker process is the heart of ASP.NET web application runs on IIS.
What is Application Pool?
Simply to say about what is application pool is: A group of one or more URLs are served by a particular worker process or set of worker processes.
Application pool is the container of worker process. Application pools are used toseparate sets of worker processes that share same configuration. Application pools enable a better security, reliability, and availability for any web application.
The worker process servers as the process boundary that separates each application pool so that when one worker process or application is having an issue or recycles, other applications or worker processes are not affected. This makes sure that a particular web application doesn’t impact other web application as they are configured into different application pool.
Application pool with multiple worker process is called “Web Garden”.
http://msdn.microsoft.com/en-us/library/gg552610.aspx
Why are application pools important?
They provide a way for multiple sites to run on the same server but still have their own
worker processes and identity.
Note:
• Isolation of Different Web Application.
• Individual worker process for different web application.
• More reliably web application.
• Better Performance.
How to find the application pool account for a web application?
Go to IIS settings (type inetmgr in command mode) and select the web application on left pane and click on the “Basic Settings” on the right pane.

Difference Between SharePoint Application Pages Vs Site Pages

Application Pages:
  • Application pages are stored in the server’s file system. 
  • SharePoint Designer tool cannot be used with application pages. 
  • Application pages cannot be used within sandboxed solutions. 
  • An Application page cannot be customized and modified by end user, instead a developer is required. 
  • These are the normal .aspx pages deployed within SharePoint. Most common of them are the admin pages found in _layouts folder.
  • These are deployed either at the farm level or at application level. If they are deployed within _layouts folder or global SharePoint Virtual Directory, then they can be used by any SharePoint application (available at farm level), otherwise they can be deployed at application level only by creating a virtual directory.
  • These are typical ASP.Net aspx pages and can utilize all of the functionalities available within ASP.Net including code-behind, code-beside, inline coding etc.
  • These are compiled by .Net runtime like normal pages.
  • If you deploy your custom ASPX pages within _layouts folder or within SharePoint application using a virtual directory, you will not be able to use SharePoint master pages and have to deploy your master page within the virtual directory or _layouts folder.
  • Application Pages cannot use contents as this concept is associated with SharePoint Page Layouts not with ASP.Net.
  • Since application pages are compiled once, they are much faster
  • Normally application pages are not web part pages, hence can only contain server controls or user controls and cannot be personalized by users.
  • Easiest way to deploy your existing ASP.Net web site within SharePoint is to deploy its pages as Application Pages within SharePoint. In this way you can convert any ASP.Net web solution as SharePoint application with minimal efforts.
  • SharePoint specific features like Information Management Policies, Workflows, auditing, security roles can only be defined against site pages not against application pages.
  • Application pages can be globalized using Resource files only. 
Site Pages:
  • Site Pages is a concept where complete or partial page is stored within content database and then actual page is parsed at runtime and delivered to end-users.
  • Site pages can be edited by using SharePoint Designer tool.
  • Site pages are used within Sandboxed solutions. 
  • A site page can be customized and modified by end user. 
  • Pages stored in Pages libraries or document libraries or at root level within SharePoint (Wiki pages) are Site Pages
  • You must be thinking why we should use such pages? There are many reasons for this. One of the biggest catch of the SharePoint is the page layouts, where you can modify page once for a specific content type and then you can create multiple pages using the same page layout with different contents. In this case, contents are stored within database for better manageability of data with all the advantages of a data driven system like searching, indexing, compression, etc and page layouts are stored on file system and final page is created by merging both of them and then the outcome is pared by SharePoint not compiled.
  • Site Pages can contain web parts as well as contents placeholders, and all of them are stored per page-instance level within database and then retrieved at run time, parsed and rendered.
  • Another advantage is they are at user-level not at web-application or farm level and can be customized per site level.
  • Since their definition is retrieved from database, they can utilize master pages stored within SharePoint masterpages library and merged with them at run time for rendering.
  • They are slower as compared to Application pages as they are parsed everytime they are accessed.
  • SharePoint specific features like Information Management Policies, Workflows, auditing, security roles can only be defined against site pages not against application pages.
  • Since they are rendered not compiled hence it is not easy to add any inline code, code behind or code beside. Best way of adding code to these pages is through web-parts, server controls in master pages, user controls stored in "Control Templates" folder or through smart parts. If you want to add any inline code to master page, first you need to add following configuration within web.config:<PageParserPaths>
            <PageParserPath VirtualPath="/_catalogs/masterpage/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />
    </PageParserPaths>
  • To add code behind to SharePoint master pages or page layouts.
  • Since Site pages are content pages, hence all SharePoint specific features like Information Management Policies, Workflows, auditing, security roles can only be defined against site pages.
  • Variations can only be applied against Site pages for creating multilingual sites.
  • "SPVirtualPathProvider" is the virtual path provider responsible for handling all site pages requests. 

SharePoint 2010 CSS: List of Useful Styles

Below is my list of useful styles that I have used so far. Click styles to see screenshot and default style settings.
@charset “utf-8″;
/* CSS Document */
/* I changed the text color in the body to black  */
body  {
color: black;
}
/* The very top bar (dark blue by default). I added the /selbg.png to get the gradient effect, and changed the bg color */
.ms-cui-topBar2 {
background:url(“/_layouts/images/selbg.png”) repeat-x left top;
background-color:#500000;
}
/* The middle title area with the logo */
.s4-title {
background-color:#c8BD9b;
}
/* The top header area. I customized the bg-color to #500000 */
body #s4-topheader2 {
background:url(“/_layouts/images/selbg.png”) repeat-x left top;
background-color:#500000;
}

/* The top menu items */

.s4-toplinks .s4-tn A.selected {
background-color:#ccc;
border-color:#cccccc;
font-weight:bold;
}
/* Top Menu Parent (static) Menu Items */
.s4-tn LI.static > .menu-item {
background-color:#666666;
background-image:none;
border-left: white 1px solid;
border-right: white 1px solid;
color: #FFFFFF;
}
/* Top Menu Child (dynamic) Menu Items in drop-down menu */
.s4-tn LI.dynamic > .menu-item {
background-color:#666666;
background-image:none;
border: #333333 1px solid;
color: #FFFFFF;
}
.s4-tn LI.dynamic > a:hover {
background-color:#999;
}

/* Quick-Launch Menu */

Body #s4-leftpanel-content {
background-color:#500000;
}
/* Menu Headings and Sites */
.menu-item {
background:url(“/_layouts/images/selbg.png”) repeat-x left top;
background-color:#c8bd9b;
}
/*Menu items: parent items */
.s4-ql UL.root > LI > .menu-item {
border-top: #332c2c 1px solid;
border-left: #500000 1px solid;
border-right: #500000 1px solid;
font-weight:bold;
font-size:1.0em;
color:#003399;
}
/* Menu items: child items */
.s4-ql UL.root UL > LI > A {
background:url(“”) repeat-x left top;
background-color:#d9d1bd;
color:#003399;
padding-left:15px;
font-size:.9em;
border-top: #500000 1px solid;
border-left: #500000 1px solid;
border-right: #500000 1px solid;
}
/* Menu items */
.s4-ql UL.root > LI > .menu-item {
border-top: #500000 1px solid;
font-weight:bold;
}
/* Special Menu Items: Recycle Bin, All Site Content */
.s4-specialNavLinkList {
background-color:#c8bd9b;
border: #500000 1px solid;
}
/* Web Part Headers */
.ms-WPHeader {
background-color:#ccc;
}
/* Web Part Headers Title */
.ms-WPTitle {
color:black;
font-weight:bold;
}
/* Breadcrumb Area */
.ms-pagebreadcrumb {
background-color:#d9d1bd;
padding: 4px 0px 4px 8px;
color:#676767;
border: white 1px solid;
}
/* Web Part Body Text > A (makes it a darker blue than default blue #0072bc*/
.ms-WPBody A:link {
color:#003399;
}

Friday, August 17, 2012

Programatically Binding Values to People Picker


try
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    SPSite site = SPContext.Current.Site;

                    SPWeb web = site.OpenWeb();
                    web.AllowUnsafeUpdates = true;
                    SPList list = web.Lists["SendDocument"];
                    SPListItem item = list.Items.Add();
                    //string testuser = PeopleTo.CommaSeparatedAccounts.ToString();
                    //SPUser newUser = SPContext.Current.Web.EnsureUser(PeopleTo.CommaSeparatedAccounts.ToString());
                    item["To"] = SPContext.Current.Web.EnsureUser(PeopleTo.CommaSeparatedAccounts.ToString());
                    item["tcc"] = txtBx.Text.ToString();
                    item.Update();
                    web.AllowUnsafeUpdates = false;

                });
            }
            catch (Exception)
            {
             
                throw;
            }

Thursday, January 5, 2012

Client object Model Using Silverlight in SharePoint (Getting Records From SharePoint List)



ClientContext context = new ClientContext(ApplicationContext.Current.Url);  
  context.Load(context.Web);
  List Projects = context.Web.Lists.GetByTitle("Opportunity Financial Data");
  context.Load(Projects);           
  CamlQuery query = new Microsoft.SharePoint.Client.CamlQuery();
  string startDateFx = FirstDate.ToString("yyyy-MM-dd");
  string endDatFx = LastDate.ToString("yyyy-MM-dd");
  camlQueryXml = "<View><Query><Where><And><Geq><FieldRef Name='Created' /><Value IncludeTimeValue='FALSE' Type='DateTime'>" + startDateFx + "</Value></Geq><Leq><FieldRef Name='Created' /><Value IncludeTimeValue='FALSE' Type='DateTime'>" + endDatFx + "</Value></Leq></And></Where></Query></View>";
  query.ViewXml = camlQueryXml;
  _financialData = Projects.GetItems(query);
  context.Load(_financialData);

 context.ExecuteQueryAsync(new ClientRequestSucceededEventHandler(OnRequestSucceeded), null);


///

private void OnRequestSucceeded(Object sender, ClientRequestSucceededEventArgs args)
 {        
     Dispatcher.BeginInvoke(BindData);
 }
//The BindData method will refer the Items which are going to bind to GridView
//Note : To bind the data to gridview use the "_financialData" collection

Tuesday, January 3, 2012

Manage blocked file types (SharePoint Server 2010)


Add or remove blocked file types
Use this procedure when you want to prohibit files of a specific type from being saved or retrieved from any Web application on a server.
To add or remove blocked file types by using Central Administration
  1. Verify that you have the following administrative credentials.(You must be a farm administrator on the server.)
  2. In Central Administration, click Security.
  3. On the Security page, in the General Security section, click Define blocked file types.
  4. On the Blocked File Types page, if you want to change the selected Web application, on the            Web Application menu, click Change Web Application. Use the Select Web Application page to select a Web application.
  5.  Do one of the following:
  • To block an additional file type, scroll to the bottom of the Type each file extension on a separate line text box, type the file extension you want to block, and then click OK.
Note:
You do not have to type a file extension in the list in alphabetical order. The next time you open the list, the file extension you added will be correctly sorted in alphabetical order.

· To stop blocking a file type, select a file type from the list, press the Delete key, and then click OK.

Thursday, September 15, 2011

Programatically Getting url of site


SPSite osite = new SPSite(Request.QueryString["SiteURL"]);
            SPWeb rWeb = osite.RootWeb;
            //siteName.Text = rWeb.Title;
            SPWeb oweb = osite.OpenWeb();
           // webName.Text = oweb.Title;
            SPList ilist = oweb.Lists[new Guid(Request.QueryString["ListID"])];
            SPListItem iitem = ilist.GetItemById(Convert.ToInt16(Request.QueryString["ItemId"]));
           // listName.Text = ilist.Title;

            lblurl.Text = rWeb.Url + "/" + oweb.Title + "/" + ilist.Title;