Pages

Sunday 24 March 2013

How to increase the timeout for an app pool when attaching from Visual Studio

As a developer you have to attach to the w3wp process from Visual studio to debug your code. This is straight forward, from Visual studio > tools > Attach to Process. (Note: To find the correct w3wp process, refer to this post)

But the problem is that you never have enough time to step through your code as the pool recycles. In order to increase the time so the process is attached and you get a lot longer to debug your code, follow these steps:

  1. In your development environment, open server manager or open IIS manager
  2. Under application pools > right the correct app pool and click on advanced settings > Change these 2 settings:
  3. Ping Enabled: Set this to False and Ping Maximum Response Time (seconds): Set this to 4294967 (which is the highest you can set)

And that's it, now you will see that you can attach to correct process for lot longer.

How to find the w3wp ProcessId when attaching to process from Visual Studio


When debugging from Visual Studio, you have to attach to the correct w2wp process.

To find the right w3wp process on a windows server 2008 R2 running IIS 7.5, run the following command:

  1. Open command prompt (right click run as administrator)
  2. if not already at c:\windows\system32. navigate to the location by this command cd   c:\windows\system32\inetsrv
  3. use this command to get a list of all the w3wp process
    appcmd list wp
  4. Identify the correct process from the list

That's is, now you can attach to the correct process rather than attaching to all :)

Monday 11 March 2013

Include managed meta data in your core search results web part SharePoint 2010

Issue:

So you have been asked to display managed metadata fields in your core results. These are the general steps I follow:

1: Add the managed metadata property to the Managed Property in Search Administration in CA. Here is how to do this: follow this blog post.

2: After you run a full crawl (ensure you have at least 1 item with data populated), we need to modify the core results web part to display the information. For example purpose we will call our field Visible-Internal (this is basically the department field which is a managed metadata field)

3: First we need to ensure that the field is actually being pulled: So navigate to your search page, edit the page and edit the search core results web part. Under Display Properties > Untick "Location Visualisation" > Click on XSL Editor, copy and save the existing text and then modify with the following code:

I generally use Notepad++ to make any changes

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xmp><xsl:copy-of select="*"/></xmp>
</xsl:template>
</xsl:stylesheet>


The above code displays all the fields that search is indexing, ensure your field is showing up in here, in our instance it is <visible-Internal>DATA</visible-internal>

4: Now for the fun part (well not so fun part), we need to format the results, by default Managed metadata is displayed as follows:

ID;#Value|GUID

This is fine but in order for a richer search experience we will look at formatting the results so we only display the "Display Name: VALUE"

5: Open XSLT editor and replace with the saved Text in Step 3

6: Add this to the top section of the XSLT code:
<xsl:param name="FieldName" /> in our case it is <xsl:param name="Visible-Internal" />

7: Under XSL:Choose add the following field:
            <xsl:if test="string-length(visible-internal) &gt; 0">  
                 <xsl:text disable-output-escaping="yes">&#8195;</xsl:text>
                 <xsl:value-of select="$visible-internal" />
                 <xsl:value-of select="visible-internalr" />
             </xsl:if>


8: Add this under <div class="srch-Metadata2">
    <xsl:call-template name="visible-internal">
    <xsl:with-param name="visible-internal" select="visible-internal" />
    </xsl:call-template>


9: Search for <xsl:template name="DisplayAuthors"> and add the following code:

 <xsl:template name="Visible-Internal">
    <xsl:param name="visible-internal" />
    <xsl:if test='string-length($visible-internal) &gt; 0'>
     Visible to:<xsl:value-of disable-output-escaping="yes" select="substring-after(substring-before($visible-internal, '|'),';#')"/>
     <xsl:text disable-output-escaping="yes"><![CDATA[&nbsp;]]></xsl:text>
     <xsl:text disable-output-escaping="yes"><![CDATA[&nbsp;]]></xsl:text>
    </xsl:if>
</xsl:template>


The magic happens in substring-before and substring-after.

10: Copy and paste it in the XSL editor and save the properties, you will have to save the page and close. Once you refresh, you should see your data as Visible to: Internal Staff

Hope this helps and please share your feedback.

Thursday 7 March 2013

Issue: Anonymous access site kept throwing 401 Resolution: View a list of all unpublished or checked out items

Issue:
 
Recently I had an issue where an anonymous site kep asking for user credentials, which was weird because the web app was set to anonymous and other sites did not prompt for authentication.

Resolution:

Turns out there were a lot of items that did not have a publsied version or had it checked out and were in draft state.

To find all unpublsied or draft versions:

Nagivate to "Manage Content and Structure > View: All Draft Document"

There are other various view that can help namely:

"Related Resources" - Which highlights all the other fiels that might have been checked out.


 

Monday 4 March 2013

Quick Launch links randomly disappear SharePoint 2010

Issue:

Recently a client had complained that the navigation items under current navigation (quick launch) in a sub site where disappearing. The user was removing them and it looked as if they were just dropping out. If the user went back and added those items again, then they appeared under quick launch


Resolution:

This solution posted at [1] seem to help a few so will try this fix:
  1. On the parent site of the site having the problem, create a “dummy” document library and leave the “Display on Quick Launch” option set to “Yes”. Once the library has been created, remove permission inheritance for the document library and the problem will be resolved for all sub-sites underneath this parent.
Yet to try out this option as the client had just added the navigation items back in, waiting for this to happen again so can apply this fix. Will update this post if Option #1 works for me


Ref:
 [1] http://social.technet.microsoft.com/Forums/pl-PL/sharepoint2010setup/thread/4439a80d-8e3e-4795-a21f-e63c221ed06b

Add new MIME type - open PDF files directly in browser


Unable to open PDF/HTML/XML files directly in browser in SharePoint 2010? Default configuration of SharePoint 2010 does not consider PDF documents safe for displaying in the browser.This script adds new MIME type to "AllowedInlineDownloadedMimeTypes" property list of defined SharePoint 2010 Web Application.


 
If ( (Get-PSSnapin -Name "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null ) { 
    Add-PSSnapin "Microsoft.SharePoint.PowerShell" 
} 
 
Get-SPWebApplication 
 
$WebApp = Get-SPWebApplication $(Read-Host "`nEnter Web Application URL") 
 
Write-Host `n"Mime Type Examples:"`n"application/pdf, text/html, text/xml"`n 
 
If ($WebApp.AllowedInlineDownloadedMimeTypes -notcontains ($MimeType = Read-Host "Enter a required mime type")) 
{ 
  Write-Host -ForegroundColor White `n"Adding" $MimeType "MIME Type to defined Web Application"$WebApp.url 
  $WebApp.AllowedInlineDownloadedMimeTypes.Add($MimeType) 
  $WebApp.Update() 
  Write-Host -ForegroundColor Green `n"The" $MimeType "MIME type has been successfully added." 
} Else { 
  Write-Host -ForegroundColor Red `n"The" $MimeType "MIME type has already been added." 
}


Ref:
http://gallery.technet.microsoft.com/scriptcenter/Add-new-MIME-type-open-PDF-f6c57c32

Nintex Workflow would not start automatically after publishing in SharePoint 2010

Issue:

The workflow was set to automatically start when a new item was created and an existing item was modified. After adding a new item the workflow did not start and when selected the item and clicked on the workflow button from the ribbion there was error message "user cannot be found". Checked the server event logs and the following message was recorded:

Error loading and running event receiver Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver in Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c. Additional information is below.

: User cannot be found.
Event ID: 6875


Debugging steps

I took over someone else and had to background knowledge as what had happened earlier. The current site was a SP 2010 site, with Nintex workflow 2010.
  • I tried creating a test workflow and that failed to start as well
  • created a test workflow in a different site collection and this worked fine, so the issue was with the current site collection

 Resolution:

I opened up SharePoint designer and clicked on wokflows, to my surprise I found that the out of the box user was set to a claims based format e.g. "0;#id", but the current web application was classic mode so I edited the workflow and saved it back (did not make any changes, just opened and saved) this updated the workflow with my current user id.

After which the workflows started working.

Hope this helps :)