Tuesday, 15 November 2016

502 - Web server received an invalid response while acting as a gateway or proxy server.

I had a problem in an ASP.Net web application hosted on IIS 8.0 and there was ARR server to load balance requests.

The error was as follows, sometimes when I hit the URL the below error appears and when I refresh the page the error disappears.

502 - Web server received an invalid response while acting as a gateway or proxy server. There is a problem with the page you are looking for, and it cannot be displayed.

When investigating the issue I found that it was happening randomly and happened always for long requests (when I upload a file or requesting heavy pages).
After lots of searching I found that the error code is 502.2 which related to 
  • 502.2 - Bad gateway: Premature Exit.
as per Microsoft error codes for IIS in the below link 

And the solution was very simple, Just increase the ARR request timeout as the below screenshots




Important Note: If you are using IIS 7.0 or 7.5 you can take a loot at the below hotfixes from Microsoft, would be helpful

Tuesday, 18 October 2016

[IE] Internet Explorer keep asking for user credentials


I had an issue in my company's product which is Internet Explorer was asking about user credentials on every request.
Despite the user is submitting the correct username and password but IE was asking again about it.
The issue was happening on IE and firefox however it was working fine with google chrome.
The issue was in loop back check, it had to be disabled for the site URL.
The below article helped me a lot in this fix, hope it'll be helpful for you.

https://blogs.technet.microsoft.com/sharepoint_foxhole/2010/06/21/disableloopbackcheck-lets-do-it-the-right-way/


Best Regards,
Ahmed Gamal

Tuesday, 31 May 2016

Error while deploying WSP on SharePoint

The below error appeared when I was deploying Exam Expert WSP.

Some of the files failed to copy during deployment of the solution

I was deploying using -GacDeployment and -Force parameters and failed however when I tried to deploy this dll to GAC it had no problems.

The problem was in SharePoint Timer and Administration services, for some reasons they were not able to perform this operation.
After restarting these services, everything went well.
SharePoint Administration Service
SharePoint Timer Service

Monday, 28 March 2016

IE: No save option when clicking on downloadable link

Problem: 
When clicking on any file (specially office files) using IE the tool bar shows open/cancel options only and no save button is there

Solution: 
The idea is that IE for unknown reason shows Open/Cancel dialog instead of Save/Open/Cancel dialog.
There's a solution in which Save/Cancel dialog will be appeared instead of Open/Cancel dialog.
It's done by adding additional response header "X-Download-Options: noopen".

By using this header we force IE to hide Open option in the dialog so it shows Save button instead of it.


Regards,
Gamal

Monday, 14 September 2015

SharePoint 2010: Restore a site deleted from SharePoint designer

We had a situation which is when deleting some old content from SharePoint designer we accidentally deleted a site and needed to restore it again.
After a lot of searching we found that it's very hard to restore content which deleted from SharePoint designer and we didn't want to restore the all farm as it's time consuming and risky for us.
So we found only one way to do this, by restoring from the content database (fortunately we had a backup from it)

The below steps explain how to restore your SharePoint deleted site from content database, hope it'll be helpful for you.

Method #4: Restore from an Unattached Content Database

SharePoint 2010 provides a really useful feature: If you have a backup of the content database, you can restore it somewhere and browse its contents from inside Central Administration.
Note: This method may not work if the content database was using a different version of SharePoint. It definitely will not work if the content database was using SharePoint prior to SP1, and the current version of SharePoint is on SP1 or later, as SP1 alters the schema of all content databases.
Also note that SharePoint uses the Farm Account to log into the database. If the Farm Account does not have access to the database, this method will not work.
To restore from an unattached content database
(1) In Central Administration, select Backup and Restore.
18(2) Under Granular Backup, choose Recover data from an unattached content database.
19On the next screen, enter the database server name and database name. Choose the authentication (Windows or SQL – if SQL, enter account name and password), and then select an operation: Browse content, Backup site collection, or Export site or list.
20(3) Click Next.
On this screen, you can select the site collection, site, list, and operation (backup or export).
21(4) Optionally select a different Site Collection, Site, or List by clicking the drop-down. Choose Backup site collection or Export site or list, and click Next.
In this scenario, we will assume you selected Export.
(5) On the next screen, for filename, provide a UNC path plus a filename with *.cmp extension (this is the typical extension SharePoint uses for exports). Optionally selectOverwrite existing files and/or Export full security. For the Export versions, you can select All Versions, Last Major, Current Version, or Last Major and Last Minor.
22
(6) Click Start Export to begin the export process.
SharePoint shows export progress on the screen. Periodically click Refresh to force the screen to update. If the export succeeds, a Succeeded message displays across from Previous Job.
23
In the path provided earlier, you will find two files, the exported data (*.cmp) and a log file, example:
24
To import this data into SharePoint, use the PowerShell command Import-SPWeb as explained here: http://msdn.microsoft.com/en-us/library/ff607613.aspx. Example:
Import-SPWeb http://intranet.sharepoint.com/somesubsite/anothersite –Path export.cmp –IncludeUserSecurity –UpdateVersions Overwrite
For more information about restoring from an unattached database, see this article:

References: http://www.proactivespeaks.com/2013/05/07/sharepoint-2010-six-ways-to-recover-lost-content/

Monday, 7 September 2015

Visual Studio 2015 Access Denied for Microsoft Windows (KB2999226)


I was installing Visual Studio 2015 community on Windows 8.0 and faced access denied error as below

After searching and reading log file I found the error related to missing windows updates needed for visual studio.
Visual Studio was searching for the update on the computer but failed to find it then fire this error.

The fastest way for fixing this problem was installing this windows updates manually (it was hard to find it on Microsoft website).
The below link contains the updates I was looking for along with other updates could be helpful for others.

"Windows8-RT-KB2999226-x64.msu" is the update which fixed my problem.

Hope it'll be helpful post.

Ahmed Gamal

Wednesday, 5 November 2014

Token Text in state EndRootElement would result in an invalid XML document

Problem:  After migrating our solution from SharePoint 2010 to SharePoint 2013 we found an error related to custom XSL file.
The XSL itself was well formed and the generated XML also was fine but we had the below error
"Token Text in state EndRootElement would result in an invalid XML document. Make sure that the ConformanceLevel setting is set to ConformanceLevel.Fragment or ConformanceLevel.Auto if you want to write an XML fragment."

Root Cause:



Solution: After investigation I had found that there's a problem might occur in XSL with SharePoint 2013 related to referencing Javascript tags inside XSL.



Hope it helps you.

Best Regards
Ahmed Gamal

Sunday, 10 August 2014

The media set has 2 media families but only 1 are provided


Issue

While attempting to restore your database using MyLittle Backup you receive the following error:

"The media set has 2 media families but only 1 are provided"

Cause

This error is due to your backup being divided into more than one part at the time of creating your initial backup file. The backup will need to be repeated so that it is contained in one file only.
In the example screenshot below you will see that there are two paths listed for the backup destination, which will create a backup over two files.

Resolution

Remove one path from the backup destination so that only one .bak file is created and then restore this file using MyLittleBackup.


You can know more details about the issue from Microsoft PM who owns SQL backups
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/abf50e00-c9b0-4809-9e61-43ed8a53e968/the-media-set-has-2-media-families-but-only-1-are-provided?forum=sqltools

The solution was copied from the below link
http://www.net24.co.nz/kb/article/AA-00125/17/Microsoft-SQL-Server-Hosting/MyLittle-Backup-Restore-Error-The-media-set-has-2-media-families-but-only-1-are-provided.html

Hope it helps you
Best Regards
Ahmed Gamal

Monday, 28 April 2014

Cloning in .net



Cloning C# objects is one of those things that appears easy but is actually quite complicated with many "gotchas." This article describes the most common ways to clone a C# object.

The below article is so good for understanding what's the differences between clone and shadow in .net.
it also will go throw sample implementation with nice examples 
hope you enjoy it.
http://developerscon.blogspot.com/2008/06/c-object-clone-wars.html
http://msdn.microsoft.com/en-us/library/system.object.memberwiseclone.aspx

Sunday, 13 October 2013

A More Efficient Method for Paging in SQL Server stored procedure

Hello guys,

If you have large result sets in your database and want to build an efficient paging through SQL Server stored procedure, I recommend the below article for you.
It's tested and gave good results.

http://www.4guysfromrolla.com/webtech/042606-1.shtml

Note: in this article he works on table Id but if you want to use other column just put a non-clustered index on it and use as below

CREATE  PROCEDURE [dbo].[usp_PageResults_NAI] 
(
    @startRowIndex int,
    @maximumRows int
)
AS

DECLARE @firstColumnDate datetime, @startRow int
 
SET ROWCOUNT @startRowIndex
SELECT @firstColumnDate = DateAdded FROM employees ORDER BY DateAdded

SET ROWCOUNT @maximumRows

SELECT e.*, d.name as DepartmentName 
FROM employees e
WHERE DateAdded>= @firstColumnDate
ORDER BY e.DateAdded
SET ROWCOUNT 0

GO 


I hope it'll help you :)
Best Regards.
Ahmed Gamal

Monday, 17 June 2013

The powerful of CSS


I didn't know before that CSS can make this shapes very easy.
it's really amazing.
take a look at http://css-tricks.com/examples/ShapesOfCSS/



Saturday, 29 December 2012

Algorithms and Data Structure Lectures (Arabic)


Hi everyone,

Now I bring to you some Algorithms and Data Structure lectures in Arabic for those who are interested.
it'll be very helpful for understanding with examples and code analysis.


http://www.youtube.com/user/FCIHOCW/featured

it's a great series that will definitely help you.

Best Regards.

SQL Server Interview Questions and Best Practice

Hello every one.
I hope you are doing great.

I found this site which is talking about SQL Server (Interview Questions, Best Practice for some users, white papers about Performance and others)
I found it useful for me, hope you find it too.

http://www.mssqltips.com/

I hope you will enjoy it.


Tuesday, 18 December 2012

Improving .NET Application Performance and Scalability

Hi there...
As the title of the post says, and as I think it's one of the most important matter for developers (which some of us don't give a damn for).
below some best practice for increasing the performance of your ASP.Net application, I hope it'll help you.

1. ASP.Net Best Practices for High Performance Applications:

http://www.codeproject.com/Articles/13100/ASP-NET-Best-Practices-for-High-Performance-Applic


2.  50 Tips to Boost ASP.Net Performance

http://www.aspnet101.com/2010/03/50-tips-to-boost-asp-net-performance-part-i/


3. and for sure we can't forget MSDN

Improving .Net Application Performance and Scalability

http://msdn.microsoft.com/en-us/library/ff649152.aspx




Hope it'll be helpful for you :)

Regards,
Ahmed Gamal

Wednesday, 11 July 2012

Response.Redirect to open a new browser window ASP.Net


In order to use the Response.Redirect to open a link in new browser, it's so simple you just need to add small change to your ImageButton or LinkButton on ClientClick event like that



                            CausesValidation="false" OnClick="lnkInsurance_Click" OnClientClick="aspnetForm.target ='_blank';">

the code in OnClientClick event does it for you.



Hope it's helpful for you

Thursday, 7 June 2012

Converting URL to readable query string

Sometime we need to get the query string from URL when it's complex and has some character which we don't know how to map them.
Example: when you open SharePoint list for editing you will find URL like the below:

http://yourSiteRoot/English/News/Pages/Forms/AllItems.aspx?InitialTabId=Ribbon%2EDocument&VisibilityContext=WSSTabPersistence&SortField=%5fModerationStatus&SortDir=Asc&View=%7b4D9015AF%2d7ECD%2d4814%2dBAC9%2dAE402456253A%7d

if you want to map the query string to a meaningful URL you can use this site
http://www.albionresearch.com/misc/urlencode.php

I used it to convert my URL and below is the result:

http://yourSiteRoot/English/News/Pages/Forms/AllItems.aspx?InitialTabId=Ribbon.Document&VisibilityContext=WSSTabPersistence&SortField=_ModerationStatus&SortDir=Asc&View={4D9015AF-7ECD-4814-BAC9-AE402456253A}



it's very helpful, hope it helps you :)

Tuesday, 5 June 2012

Could not load file or assembly ‘RSSharePointSoapProxy'


ERROR:Could not load file or assembly ‘RSSharePointSoapProxy, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91′ or one of its dependencies. The system cannot find the file specified.

To Solve this Issue, Install the following reporting service add-in for SharePoint 2010.

http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=622

Your backup is from a different version of Microsoft SharePoint Foundation -- Sharepoint 2010

while I was going to restore a SharePoint 2010 backup I got the below error

Your backup is from a different version of Microsoft SharePoint Foundation and cann't be restored to a server running the current version. The backup file should be restored to a server with version '4.1.6.0' or later.

and after searching I found the solution 
First, make sure that you have SharePoint SP1 installed
Second after installing SP1 you must run SharePoint Configuration Wizard because the SP1 installation is updating SharePoint but you need to run the configuration wizard to update the database with the new version of SharePoint.


I hope this post will be helpful for you.

Regards,
Ahmed Gamal

Backup and Restore SharePoint site



The best way to backup a SharePoint site is –
Stsadm –o backup –url -filename
And then at a later date you can restore the site using
Stsadm –o restore –url -filename

How to identify which version of SharePoint 2010 you have installed

this is a good link which will lead you to identify the version of SharePoint 2010 installed

http://nearbaseline.com.au/blog/2010/12/how-to-check-the-version-of-sharepoint-project-server-installed/

Sharepoint 2010 Configuration: Failed to create configuration database.

Sharepoint 2010 Configuration Wizard: Failed to create configuration database.

I had faced this problem while I was running SharePoint 2010 configuration wizard
Error:
Failed to create configuration database
and the type of exception was:  "Microsoft.Sharepoint.Upgrade.SPUpgradeException"

after long search I found the solution for my case:
http://iconraja.wordpress.com/2011/09/02/sharepoint-2010-failed-to-create-the-configuration-database/

after I downloaded and installed the mentioned tool the error was solved.
I think it add permission to some registry files related to SharePoint.


I found other suggested solutions that can be helped if the above one didn't fix your problem.

1. Edit in your SharePoint registry files
http://gopika-lasitha.blogspot.com/2011/02/failed-to-create-configuration-database.html

http://edwin.vriethoff.net/2008/02/01/microsoftsharepointupgradespupgradeexception-action-12010-of-microsoftofficeserver-searchupgradesearchserviceinstancesequence-failed/


2. Add “dbcreator” security role to the SharePoint admin user:
. Run Microsoft SQL server management studio
. Go to Security –> Logins –> –> Server Roles
. Check “dbcreator” role for the user
. Re-start SharePoint products configuration wizard.


Hope this helps you.