Posts

Dynatrace - .NET Trending / Leak Analysis Memory Snapshot

Image
If you use Dynatrace, please be aware that if you are using option of ".NET Trending/Leak-Analysis Memory Snapshot" option to "Always On". (System Profile > Agent Group > Agent Mapping > Advanced), to analyze memory leaks in .NET, this may result in higher response times, elevated CPU usage on your web servers and/or higher times spent in garbage collection. These changes to time spent in garbage collection can be observed from the PurePath breakdown(s). When not in use, please set to "Automatic" (Preferred) or "Always Off" to limit the performance impact to your web servers.

ASP.NET MVC - Disabling Browser Link

Image
You may be experiencing unexpected errors and performance impacts as a result of a capability added within Visual Studio 2013, titled Browser Link. The intent of Browser Link, was to allow the IDE to (bi-directional) communicate with the browsers (using SignalR), and allow for refreshing multiple browsers at once ("via Refreshing Linked Browsers"). In the circumstance that you are experiencing the following issues, The web application / scripts being loaded, are taking extensive periods of time to load, as a result of javascript / jQuery errors being returned to the client. The CPU usage between IIS Worker Process (W3WP) is increasing outside normal bounds. HTML markup contains garbage tags, as a result of the HttpModule associated with Browser Link. You can disable the Browser Link capability, by either using Visual Studio settings, or by disabling in the web configuration. Visual Studio [ source ] In the Browser Link dropdown menu, uncheck Enable Browser Li...

C# / SQL - Performing Distributed Transactions

Distributed Transactions span across multiple processes, which when encapsulated by the distributed transaction manager, will either commit a successful transaction or rollback changes. Distributed Transactions have been available within .NET, since .NET Framework 2.0. The Default Isolation level is set to Serializable , which in usage, creates unnecessary blocking and deadlocks. Therefore, it is suggested you override the default isolation level to ReadCommitted, which reflects the default within SQL Server. /// /// This class is responsible for performing Distributed Transactions. /// public class DistributedTransactionUtility { /// /// The Distributed Transaction method which creates a Transaction Scope object /// and commits if there is no error and rollbacks, incase of exception. /// /// /// The method which performs multiple DB Transactions. /// public void DoDistributedTransaction(Action method) { // Initializes Transac...

ASP.NET MVC / IIS - Optimizing Web Application Performance

Optimizing your web sites in ASP.NET MVC for performance includes cache busting, enabling caching for static resources, enabling gzip compression. To enable caching on static resources, you will need to add the following XML in your web configuration file in the system .webserver element. The control max age parameter determines the length of time to cache the static resources. ... ... In an effort to compress dynamically generated content (ASP, PHP, ASP.NET) and static files (PDF, JPEG, etc.), you can enable the following settings within your application web configuration. As you use < urlCompression > to define what is compressed, you can use < httpCompression > to define how it is compressed. … Utilizing Cache Busting can be done to ensure users do not need to clear their browser cache (te...

ASP.NET MVC - Using CDNs (Content Delivery Network)

By utilizing content delivery networks (CDN)s, you will potentially receive several benefits including improved performance, gains from using different domains, pre-cached files, high-capacity infrastructure and distributed data centers. A CDN can distribute the load, save bandwidth, and boost performance. As individual users request static resources such as javascript and stylesheets, browsers limit the number of concurrent connections (or file downloads) to a single domain at a given time, thus allowing users to download additional requests. Additionally, many CDNs provide localized data centers which are closer to the user, and faster to download. For example, if you are browsing your application's site in San Francisco and need to download the javascript or stylesheets, assuming the CDN has a datacenter in California, it would utilize that location to download the file opposed to making the round trip to your local servers (e.g. could be hosted across the country). In terms of...

SharePoint - Moving Sites and Subsites into another Site

If there is a need to move sites and subsites into another site within the same web application, this can be easily performed using the "Site Manager". Often times, this option is over-looked, in favor of site templates, or other backup and restore operations. However, this is the simplest option available. Note: This site is available on "SharePoint Online or Office 365 Dedicated" as well as any stand-alone SharePoint installation, on the basis that you activate the Publishing Features within SharePoint. If you visit "http://enter_your_site_url/_layouts/sitemanager.aspx", you'll see the Site Manager, where you can do a move operation of all pages and sub-sites. Select the parent site of the sub-site you want to move in the left navigation pane. Check the box next to the sub-site you want to move in the right pane. Click the Actions drop-down and click Move . Select Destination of the sub-site selected in the next dialog. SharePoint Sta...

SharePoint - Feature with ID already exists - Force Option

Occasionally, when deploying SharePoint Solutions (WSP) directly from Visual Studio, you will receive the following error. Error occurred in deployment step 'Add Solution': A feature with ID {Guid} has already been installed in this farm. Use the force attribute to explicitly re-install the feature. This error occurs when you have a previously defined feature installed, as part of the same solution, which will trigger the error. To overcome this issue, you can open the feature (double-click) which is part of your actual project, and you will see the properties window come into focus. In this window, you will see details, such as title, description, scope, items in the feature. In the property window, you'll see an option titled 'Always Force Install'. By default, this item is set to "false". If you set this option to "true", it will over-write the feature each time the project is installed. SharePoint Stack Exchange

C# - Performance Counters

Reading performance counters (in C#) require the use of the PerformanceCounter class to read existing predefined or custom counters. The PerformanceCounter class is included in the System.Diagnostic namespace, and provides accessibility to several counters. The most common counters include Processor, Memory, and Network Utilization. // CPU Processor Time (in %) PerformanceCounter cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total"); Console.WriteLine("Current CPU: {0}", cpuCounter.NextValue() +"%"); // Memory Available (in MB) PerformanceCounter ramCounter = new PerformanceCounter("Memory", "Available MBytes", string.Empty); Console.WriteLine("RAM Available: {0}", ramCounter.NextValue()+"MB"); // Network Utilization (in Bytes/Sec) PerformanceCounterCategory category = new PerformanceCounterCategory("Network Interface...

SharePoint - An unexpected error has occurred. (Web Part Page Maintenance)

Image
On occasion, a web part may be causing your SharePoint pages to throw an unexpected error. An unexpected error has occurred. Web Parts Maintenance Page: If you have permission, you can use this page to temporarily close Web Parts or remove personal settings. For more information, contact your site administrator. Troubleshoot issues with Microsoft SharePoint Foundation. In addition to leveraging the ULS Logs , to investigate the Correlation ID, you can append " ?contents=1 " to your page URL. This will allow you to close web parts, restore defaults to web parts, or delete web parts from your page.

IIS / ASP.NET - Disabling Compatibility Mode/View (Internet Explorer)

In ASP.NET, if you need to disable compatibility view of the end users using your application, you can override the respective browser (Internet Explorer) compatibility mode, by setting the compatibility mode to Edge. By using this setting, the users of the web application, will render using the latest rendering engine available. If in the scenario you don't want to use the latest, you can also define other standards, such as IE8, IE9, etc. This can be defined in the master page/view using the following meta tag within the <head> section: ... Note: The X-UA-Compatible meta tag will need to be the first meta tag, in the circumstance that setting the IE rendering engine to Edge, is not working as intended. and web.config, by adding a custom header using X-UA-Compatible to the response headers, ...

IIS / ASP.NET - Run all Managed Modules for All Requests (RAMMFAR)

When initially creating an ASP.NET web application, RunAllManagedModulesForAllRequest is enabled by default. If enabled, every request that passes through the ASP.NET pipeline, is treated as a managed modules (or handlers). When all modules are managed, including static content, there are possible performance implications. If you are utilizing a distributed cache provider, such as App Fabric, an implication includes that all managed resources, including static content are passed to the distributed cache (as managed resources), which adds a level of overhead, even if not required. The solution to optimizing your web application, is to disable runAllManagedModulesForAllRequests (RAMMFAR), and add defined locations for your static resources within your web configuration file. The static resources can include but are not limited to CSS, Images, and Scripts. Firstly, you will want to add location segments for each file/folder location, within the configuration element. ... ...

SharePoint – The current operation could not be completed. Try again, or contact your system administrator.

If attempting to utilize Site Manager, to COPY an entire site or any particular pages, and receive the following error. The current operation could not be completed. Try again, or contact your system administrator. You may re-try the operation, and you may need to clean up the half-created data first before re-trying. If the problem persists, please contact your system administrator. If you review the logs, and the following is displayed, System.ArgumentException (0×80070057) Microsoft.SharePoint.Library.SPRequestInternalClass.GetMetadataForUrl(String bstrUrl, Int32 METADATAFLAGS, Guid& pgListId, Int32& plItemId, Int32& plType, Object& pvarFileOrFolder) at Microsoft.SharePoint.Library.SPRequest.GetMetadataForUrl(String bstrUrl, Int32 METADATAFLAGS, Guid& pgListId, Int32& plItemId, Int32& plType, Object& pvarFileOrFolder) at Microsoft.SharePoint.SPWeb.GetFileOrFolderObject(String strUrl) at Microsoft.SharePoint.Publishing.CommonUtilities.GetFile...

SharePoint – Web Service Requests in InfoPath Forms (Classic to Claims)

Image
Without writing code, you can populate User Profile Service (UPS) information into your fields in InfoPath forms. This process is clearly defined in the following  blog . However, as this works perfectly, in the classic-based authentication there are several modifications that will need to be made, to fully utilize the forms, as a result of product limitations caused by Claims-based authentication. Firstly, a Secure Store ID will need to be created in Central Administration (Manage Service Applications), you’ll need to assign the Target Application ID, and add the Target Application Administrators which would ideally need to be a generic ID that never expires, and the members that are mapped to the credentials defined. You’d need to then set the credentials on that domain account for the secure store target application. Lastly, under Central Administration (General Application Settings), and InfoPath Forms Services, the option to ‘Allow user form templates to use authentication ...

SQL – Locked in Single-User Mode

If you ever want to see what sessions are active in SQL, or if you ever perform a SharePoint Backup through Central Administration, and SQL Server goes into single-user mode and does not remove that state – the following SQL query will return all active user sessions, by ID. select d.name, d.dbid, spid, login_time, nt_domain, nt_username, loginame from sysprocesses p inner join sysdatabases d on p.dbid = d.dbid where d.name = 'db_name' GO Once you get this ID, you can just manually kill the session, to the ID, and then disable single-user mode in the respective tables, etc.

SharePoint 2010 - Remove / Disable Themes

If you've ever encountered the need the disable themes on a site collection, there are a few options you may have available. Firstly, there are policies in Central Administration to remove the ability to change the themes across the entire web application, which can be done by the following: Visit Central Administration > Application Management > Web Applications > Manage Web Applications. Select the Web Application that you want to restrict the themes on. Click on "Permission Policy Level" on the Ribbon. Name the policy, and find the permission "Apply Themes and Borders" and toggle the "Deny" check box. Click save. Click on "User Policy" on the Ribbon. Add the users and groups you want to restrict, and then apply the policy you just created. Alternatively, if you want to manually remove the themes, you can update the theme entries, in a file called: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\...

SharePoint 2010 - Cannot access the local farm.

Issue: If you're encountering the following error, when trying to run a powershell script, you may not have sufficient permissions on the database. Get-SPWeb : Cannot access the local farm. Verify that the local farm is properly configured, currently available, and that you have the appropriate permission to access the database before trying again. The issue can be remedied with a few quick powershell commands. Workaround: Perform the following script in the SharePoint Management Shell, as a farm administrator and it will remove the error. Get-SPDatabase | Add-SPShellAdmin SomeDomain\SomeUserName This will grant the user both access to the configuration database as well as the content database. Alternatively, you can revoke that granted access with the opposite command. Get-SPDatabase | Remove-SPShellAdmin SomeDomain\SomeUserName

SharePoint 2010 - The site is not valid. The 'Pages' document library is missing

Issue: If you're encountering the following error, via ULS, or the event log, due to a page library, This site is not valid. The 'Pages' document library is missing. The issue can be remedied with a quick powershell script. Workaround: Perform the following script on the page library causing the issue, and it will remove the error. $web = get-spweb http://somesite/somesubsite $pageId = $web.Lists["Pages"].ID $web.AllProperties["__PagesListId"] = $pageId.ToString() $web.Update()

SharePoint 2010 - Improving Chrome Support

Certainly, if you've utilized Google Chrome to browse SharePoint 2010 pages you've noticed the inflexible behavior caused by the on-demand javascript. You almost always have to refresh to ensure that the javascript functionality works - Modal Dialogs, Ribbon, etc. With some minor updates to the master page, you should be able to utilize Google Chrome without any problems. Firstly, you'll want to add some additional items in the <head> tag. Afterwards, at the bottom of your page just above the closing </body>, add the following javascript. // Attempt to detect if this is iframe content if (location.href == top.location.href) { if(navigator && navigator.userAgent && /chrome/.test(navigator.userAgent.toLowerCase()) && $){ $(document).ready(function(){ if(_spBodyOnLoadWrapper){_spBodyOnLoadWrapper();} if($("#s4-workspace") && $("#s4-ribbonrow")) { ...

SharePoint 2010 - MySite Redirection

When user's click a user's name in a document library, etc, a file userdisp.aspx controls where the user is directed. Assuming you want to have all user links bring users to My Sites, you can start off creating the user control, by the following code on http://blogs.sharepointguys.com/brendon/sharepoint-2007/programming/redirect-to-your-own-mysite-landing-page/ and then in the RedirectIfNecessary(SPListItem user) you can utilize the following code. if (Request.QueryString["id"] != null) { SPSite _site = SPContext.Current.Site; SPServiceContext _serviceContext = SPServiceContext.GetContext(_site); UserProfileManager _userProfileManager = new UserProfileManager(_serviceContext); string _mySiteUrl = _userProfileManager.MySiteHostUrl; string _profileUrl = string.Empty; int userID = 0; if (int.TryParse(Request.QueryString["id"].ToString(), out userID)) { SPUser profileUser = SPContext.Current.Web.SiteUsers.Get...

SharePoint 2010 - Current Variation / Variation Labels

If you're trying to develop a web part, which utilizes the variation title and doing so by accessing the variation labels lists in SharePoint 2010 and experiencing problems, give this function a try. I've written it to compare the accessible locales against that of the current web LCID. public static string GetCurrentWebRegionLabel() { string strLabel = "USEN"; SPSecurity.RunWithElevatedPrivileges( delegate() { ReadOnlyCollection _variations = Variations.Current.UserAccessibleLabels; strLabel = _variations.FirstOrDefault(m => m.Locale.Equals(SPContext.Current.Web.Locale.LCID.ToString())) .Title.ToString(); }); return strLabel; }