Tuesday, August 02, 2011

SharePoint Saturday "The Conference" DC 2011

Hi Folks,

We would like to share with all SharePointers who are willing to attend the SharePoint Saturday The Conference DC from 11th-13th August 2011 please register right now and check out the list of all sessions by SharePoint Experts, MCM, MVPs and Industry Information Worker (IW)
experts.

This is the biggest SharePoint Saturday event; In addition to the lineup of great speakers/sessions; the event will have workshops that deliver hands-on experience to the attendees.


What's different about SPSTC DC :
A community-focused, educational event filled with sessions from respected SharePoint professionals and executives covering a wide range of technical and business topics.

Where ?

Northern Virginia Community College

Annandale Campus, Annandale, VA

(Visit the website here.)


I will deliver a session under Dev/ITPro track with title :

Building BI solutions using Performance Point Services in SharePoint 2010
Speaker(s): Mostafa Elzoghbi
Session Level: 300
Session Type: IT Pro / Developer
In this session I will cover PPS architecture & design fundamentals in SP 2010 and how to build BI solutions using SharePoint 2010 BI Center, BIDS, and Report Builder 3.0 with different data sources using DBs and Cubes. In addition to build, design, deploy Custom SSRS Reports within SharePoint. Tips in Configuring PPS application service in SharePoint 2010 and Reporting Services in SharePoint 2010.
A demo driven session to create custom KPIs, Scorecards, Custom Reports and Dashboards.

For more information, check out the website:


See you all there !!

Regards,
Mostafa Arafa
twitter.com/mostafaelzoghbi

Friday, July 15, 2011

SharePoint Saturday NYC: PPS solutions in SharePoint 2010

Hi All,

On 30th of July 2011, We will have SharePoint Saturday Event in New York City at Microsoft-Manhattan Office. Don't miss this opportunity to meet with SPS NYC speakers line up with very informative sessions. Please check out the event website:

I will present in this event with a session name : Building PerformancePoint Services Solutions in SharePoint 2010.

In this session I will cover PPS architecture & design fundamentals in SP 2010 and how to build BI solutions using SharePoint 2010 BI Center, BIDS, and Report Builder 3.0 with different data sources using DBs and Cubes. In addition to build, design, deploy Custom SSRS Reports within SharePoint. Tips in Configuring PPS application service in SharePoint 2010 and Reporting Services in SharePoint 2010.

A demo driven session to create custom KPIs, Scorecards, Custom Reports and Dashboards.

Session Details page:

http://www.sharepointsaturday.org/ny/meetings/106/BuildingPerformancePointServicessolutionsPPSinSharePoint2010.aspx

Don't miss this event and see you all there...

Download Presentation Url:

https://skydrive.live.com/?cid=4BC94054914A6469&id=4BC94054914A6469%213331&sc=documents


Regards,
Mostafa Arafa
twitter.com/mostafaelzoghbi

Thursday, June 02, 2011

Export ASP.NET Form to PDF

Hi All,
I was trying to export the content of an ASP.NET page in my project to PDF, and after i spent few hours to figure out how to achieve this using standard Resposnse.Output() with pdf format, I ended up having different errors & bugs without successfully export a simple html page to pdf.

Having complex asp.net page with complex controls, you need simply to install iTextSharp PDF tool, easy and free tool to export your page to pdf.

Here is the steps:
1) Install iTextSharp tool : http://sourceforge.net/projects/itextsharp/
2) Add itextsharp.dll in your project.
3) Create your function to export to PDF as follows:

        protected void ExportToPDF()  
       {        
                // Start exporting page content
                string attachment = "attachment; filename=MostafaElzoghbi.pdf"; 
                Response.ClearContent();       
                Response.AddHeader("content-disposition", attachment); 
                Response.ContentType = "application/pdf";    
                StringWriter stw = new StringWriter();   
                HtmlTextWriter htextw = new HtmlTextWriter(stw); 
                // We want to render the whole page, you can change this with the control name or portion you want to export. 
                myDiv.RenderControl(htextw);      
                Document document = new Document();       
                PdfWriter.GetInstance(document, Response.OutputStream);   
                document.Open();         
                StringReader str = new StringReader(stw.ToString()); 
                HTMLWorker htmlworker = new HTMLWorker(document);  
               htmlworker.Parse(str);       
               document.Close();        
               Response.Write(document);  
               Response.End();   
         }
If you get this error: A control has to be placed inside a form tag with runat=server attribute.

Just add this function in your code to override the pre render validation step in asp.net forms:

public override void VerifyRenderingInServerForm(Control control)
 { /* Do nothing */ }

Hope this helps.


Regards,
Mostafa Arafa
twitter.com/mostafaelzoghbi

Monday, May 23, 2011

Upload Video to Facebook in C#

HI Folks,
If you tried to upload a video to facebook using facebook sdk in C#, You will face a problem that the provided method UploadVideo in LegacyRestApi.cs file accepts the full physical path of the file to be uploaded. For ASP.NET developers and since we are using AsyncFileUpload Control to select your files, this control provides only the file name and not the full physical path because of security constraints applied on all browsers. I have updated the source code and ask the codeplex product facebook sdk team to include this in the future release. and I'd like to share the updated code for this method in my blog for all facebook .NET Developers, Hope this helps.

C# Code:

public static string UploadVideo(string accessToken,string fileName, byte[] fileBytes)
 {          
   var mediaObject = new FacebookMediaObject 
    {    
       FileName = fileName,     
       ContentType = "video/3gpp" 
    };     
    mediaObject.SetValue(fileBytes);         
    try {         
              var fb = new FacebookClient(accessToken);     
              var parameters = new Dictionary<string, object>();   
              parameters["method"] = "video.upload";       
              parameters["caption"] = "video upload using rest api";   
              parameters["source"] = mediaObject;          
              var result = (IDictionary<string, object>)fb.Post(parameters);   
              var videoId = (string)result["vid"];        
              Console.WriteLine("Video Id: {0}", videoId);   
              // Note: This json result is not the orginal json string as returned by Facebook.    
              Console.WriteLine("Json: {0}", result.ToString());     
              return videoId;      
       }           
       catch (FacebookApiException ex) {     
            // Note: make sure to handle this exception.       
          throw;           
      }        
 }    
Codeplex discussion entry:


Regards,
Mostafa Arafatwitter.com/mostafaelzoghbi

Tuesday, May 17, 2011

Fix It: Sys.WebForms.PageRequestManagerParserErrorException when using update Panel in Facebook Apps

Hi All,

I was developing a Facebook application using Facebook C# SDK and i have an update panel in my page i'd like it to update a grid in it based on selected index changed event for a drop down list.

The problem is that i have the update panel was throwing an exception when i was trying to change the selected index of a drop down list, the error is :
Sys.WebForms.PageRequestManagerParserErrorException when using update Panel

This error is vague, to know exactly what is the problem of the update panel, Install Fiddler which is the best tool for any web developer should have to inspect http requests/responses.

After installing and open Fiddler to inspect all http round trips on my development machine, I found the actual error that was returned from the server is:
Given URL is not allowed by the Application configuration.
So the solution for this problem is a missing or incorrect configuration in your Facebook application. Open the configuration of your Facebook application and select website tab and set the website url for your local Facebook application is running:
Site URL : http://localhost/

Tips:
1) If you set the port number in the site url this won't fix the problem, Just set the localhost without any ports and this will fix the update panel problem is not updating because of the javascript error.
2) You can have SelectedIndexChanged event as AsyncPostBackTrigger in the update
panel and no issues with this because i read some posts were saying it has to be SyncPostBack
which is not actually right.
Hope this helps.


Regards,
Mostafa Arafa
twitter.com/mostafaelzoghbi

Monday, May 16, 2011

Automatic HTTPS redirect in Windows 2008 R2

Hi All,

I was trying to setup automatic redirect from HTTP to HTTPS for my hosted web application in IIS 7.0/7.5 Windows 2008 R2. I spent good time trying to find out a working solution for this problem.

If you tried a solution with custom error pages 403 in IIS to redirect the http to https, this won't work in windows 2008 R2 IIS 7.0/7.5 server, as stated here:


Please follow these steps to have a working solution:
1) Install URL Rewrite 2.0 on your webserver, download url:

2) After installing url rewrite module in IIS, Open IIS Manager and select your website, you will find a newly added icon "Url Rewirte"

3) Make sure to install SSL certificate on your site and site has https binding on port 443.

4) on SSL settings in IIS, un check Require SSL check - IMPORTANT, because this will overwrite the settings you will configure on URL Rewrite and will throw http 403.4 error.

5) Don't add any custom error pages for 403 as mentioned on some blog posts, if you have please remove it.

6) double click on URL rewrite and click on add rule.

7) Select Blank rule and click on ok.

8) On Name field give name to the rule: Redirect to HTTPS

9) Set the following values on the form:
- Requested URL: Select Matches the pattern
- Using: Regular Expression
- Pattern: (.*)
- Under Conditions, Click on Add and type:
Condition Input: {HTTPS}
Check if input string: Matches the pattern
Pattern: ^OFF$
- Under Action section:
Action Type: select Redirect
Redirect URL: https://{HTTP_HOST}{REQUEST_URI}
If you tried this url: https://{HTTP_HOST}/{R:1} as stated in some blogs, this won't work as well.
Redirect Type: See Other (303)

And then click on Apply.

From IIS Manager, Try to browse the application using HTTP, The IIS will direct you to HTTPS automatically.


Hope this helps.

Resources:



Regards,
Mostafa Arafa
twitter.com/mostafaelzoghbi

Tuesday, May 10, 2011

How to install NuGet Facebook Samples Package in VS 2010

Hi All,

I was trying to develop a functionality to upload a video on facebook, To achieve this, you have to include Facebook NuGet Package in your project.

The question was for me ? What's NuGet ? What's the concept of a Package ? Is it different than VS 2010 Extensions ? and how to add this to my project?

After reading few blogs and experiment this by myself, I wrote this blog post to clarify these points to any developer who hear these terms for the first time as it was for me.

What's NuGet ?
It is a VS 2010 Extension to manage third party and open source libraries in your VS 2010 project, it simplifies the process of installing/uninstalling packages in your projects without worrying about the dependencies dlls and associated files to each packages and so after uninstalling any of these packages on your project there is no clutter.

How to install it NuGet Package Manager:

Once you install this, Please restart your VS 2010.
Once you re-open your VS 2010, You will notice new menu items under tools called: Library Package Manager.
This is how you can install/uninstall packages in your solution with command line window called "Package Manager Console".

In my case, I was trying to install Facebook Sample Package in my project, How would i do that ?

Here is the steps that you need to follow:

1) Open your VS 2o1o as administrator, if you didn't do that, you might get an error when connecting to your TFS as i got Access denied.
2) Open your project and set the startup project you would like to add Facebook samples package to it. It is recommended if this is the first time, Open a new empty project and try these steps so you know exactly the added files when you install any package.
3) To explore NuGet Gallery Packages, here is the website:
For Facebook Package, here is the command you should type it in "Package manager Console":

PM> install-package facebook.sample













Now the facebook sample package has been installed successfully and you can see this in the package manager console.

Open your solution and you will find Samples Folder has been added and Facebook folder underneath it.

You can explore the code and use any of these functions in your project since all dlls and files required have been added to you.

To upload a video to facebook, Check LegacyRestApi.CS in your project and you will find a function called "Upload Video".

Enjoy and have fun with Facebook C# Development.

Let me know if you have any questions following these steps.


Regards,
Mostafa Arafa
twitter.com/mostafaelzoghbi

Monday, May 09, 2011

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding

Hi All,

If you are experiencing a problem connecting to your SQL Server 2008 R2 DB server from any remote machine in your network, Please make sure of the following:

1) You are able to ping the machine from the remote server.
2) Try to connect make sure that the SQL Server Engine service is up and running, You can open "SQL Server Configuration Manager" and make sure that the service is up and running.
3) Make sure that you have at least one protocol TCP/IP,Named Piper or Shared Memory is allowed on both your client and your DB Server and this you can check it from SQL Configuration Manager.
4) THIS FIXED MY PROBLEM: Disable the Domain firewall in the DB machine that blocks all inbound connections to your DB Server. To do this:
a) From Server Manager.
b) Under Configuration - > Select Windows Firewall.
c) Click on Windows Firewall Properties and disable your domain profile firewall.

Try to refresh your page and you will be able to connect to your DB.

Hope this helps.

Regards,
Mostafa Arafa
twitter.com/mostafaelzoghbi

Unrecognized attribute 'targetFramework' 4.0

Hi Folks,

If you tried to deploy your asp.net application on Win 08 - IIS7 and you were getting this error:
Unrecognized attribute 'targetFramework' 4.0

This means the application pool that runs your website is not configured to run under .NET Framework 4.0.

On IIS 7:
1) Click on your application pool.
2) Click on the right pane, Advanced settings.
3) Under General Tab, Select .NET Framework Version.
4) Select v 4.0.
5) Recycle your application pool by right click on it.
6) Refresh your page.

Refresh your page and it works :)

Hope this helps...


Regards,
Mostafa Arafatwitter.com/mostafaelzoghbi

Monday, April 25, 2011

SharePoint Diagnostic Studio 2010

Hi Folks,
SharePoint Product team announced a new tool for SharePoint 2010 that helps SharePoint Architects, Professionals, Developers and IW Group to maintain a health state of your SharePoiont 2010 Farm by giving your the tools and processes to monitor: Event Logs, ULS Logs, Performance counters, Performance of SQL Queries along with the events associated for SP actions/events in your farm.
We were looking long time to have this tool along with the reporting capabilites that is provided, Read more about it: http://sharepoint.microsoft.com/blog/Lists/Posts/Post.aspx?ID=971
SharePoint Diagnostic Studio Documentation:
Hope this helps.
Regards,
Mostafa Arafa
twitter.com/mostafaelzoghbi

Wednesday, March 30, 2011

CSS is not applied on login page in ASP.NET

Hi All,
If you are working with asp.net and you tried to apply css classes on your web application which is linked in your master page. You might face a problem that the css classes doesn't show on your login page but it shows properly after you logged in to your application by clicking on sign out link.

The problem is a security permission problem, since by default the asp.net application has a rule that doesn't allow all users to access folder within your project, to fix this problem, you want to allow all users to access your css file in your folder, So let's say you have css files in your Styles folder in your web project; You need to allow all users in web.config to access these files, so this fixes this problem in login.aspx page.

Add the following in your web.config to fix this issue:

<location path="Styles">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>


After applying this, try to run your application and you will see the css classes are applied in your login page before signing in or after signing out.

Hope this helps.

Regards,
Mostafa Arafa
twitter.com/mostafaelzoghbi

Monday, March 21, 2011

Deploy Your Facebook Application in Azure

Hi All,
If you trying to get started developing Facebook Applications in C#, Then you need to download facebook SDK in C#, and you can get the latest build from below link:
http://msdn.microsoft.com/en-us/windows/ee388574
After you install Facebook SDK, You will have good samples to get started and configure your application to be integrated with Facebook. After you will be able to successfully configure the first application. Then, If you want to deploy this application on Windows Azure, The question will be: How Can i deploy a sample website into Azure ? All samples provided in FB SDK are ASP.NET websites. As you might know, To deploy any web role in Azure you need to have a Web Application and Not a website. So the question how can i do this ? Please follow these steps:
1) Create a new Web Application in your solution.
2) Copy the Web.Config that you have in FB website and paste it in your web application.
3) Copy the code in Global.asax in FB Web site and paste it in your web application Global.asax.
4) You need to copy the code in FB web site master page and have it in your web application master page with updates to couple of controls.
5) Copy the code in web site default.aspx and paste it in your web application default.aspx.
6) Make sure to add latest Facebook.dll and Facebook.web.dll in your ASP.NET web application.
7) You need Facebook.MVC.dll if your application is a MVC ASP.NET application.
8) Make sure to update your web application web.config with the Facebook configuration.
9) Try to build and run your web application. You will be directed to facebook canvas page as configured in your web application.
10) Add a cloud service in your solution.
11) Add this web application as a web role and try to set the cloud service as a startup project.
Note: Make sure to target 4.0 .NET Framework.
Build & Test it out !
Hope this helps.
Regards,
Mostafa Arafa
twitter.com/mostafaelzoghbi

Monday, March 14, 2011

Thoughts & practices in Developing Cloud based solutions in Azure

Hi All,
I'm working for a while in designing and developing cloud based solutions using windows azure platform. In addition, I love working in the cloud and the concept to focus on developing business requirements rather than the infrastructure preparation and servers setup. I like the concept of the configuration management since you can build your virtual network and the server configuration form an XML file and with few clicks your project is hosted and deployed.

In this post i will share some ideas and thoughts that you might face or have in your mind when you start developing cloud based solutions.

1) Project Types: Using VS 2010, you can build different types to be hosted in windows azure, You can build web sites, web application in addition to back end services. The websites & web applications are called WEB ROLES. and back end services are called WORKER ROLES.

2) Databases: You can deploy your existing database by creating scripts in SQL 08 R2 Management studio that can have schema+data,schema only,data only and connect to the cloud DB server and run those scripts. then you db is ready to be used. The management console in Azure gives you the connection string to connect to your db under SQL azure tab.

3) DB size: As we have till now, you have 2 editions for DB: Web or Business, Web edition allow you to create DB up to 5 GB. and Business Edition allows you to create DB up to 50 GB. since we pay as we use in the cloud, you might start your project with specific size and then you need to extend this. and this is a FAQ for most of developers that have created their dbs and need to extend the DB size in the cloud

To change your DB edition and size option, check out this link:

4) VM configuration: Every deployment in Azure is a VM in the data center. So, you can configure the VM size and all deployment configurations such as: RAM,Processor,Trust level,Virtual Network setup...etc on your project before deploy it in the cloud. You can do this by right click on the cloud service project and select properties option.

To know more about how to configure your cloud project in VS 2010, check out this link:
http://msdn.microsoft.com/en-us/library/ee405486.aspx

5) Make sure to change the custom dlls required property Copy Local = True in VS 2010. So you will have them in the deployment package.

6) Here is a general troubleshooting tips for hosted services:
http://msdn.microsoft.com/en-us/library/gg465402.aspx

Hope this helps.






Regards,Mostafa Arafa
twitter.com/mostafaelzoghbi

Tuesday, March 08, 2011

How to calculate SQL Azure Storage per client in your DB ?

Hi All,
If you have a cloud based solution hosted in Windows Azure and you are using SQL Azure Database as a backend database. You will need to think about how much storage each client who is going to use your solution will consume from DB storage you have in the cloud. This concept is essential since the concept behind Software As A Service aka (SaaS) is to pay as you go. So, the client pays only for the storage he takes in the cloud and this is a competitive advantage you should give when you sell cloud based solutions.

Since you have a backend database that has all your clients data, You need to give the storage that has been taken by each client in your database. To do this, I was thinking that if i can get the Database size in MB and the size of each table.
I'd be able to calculate the storage for each client.

For example: If i have a table in my DB called Client, and set of tables Table1,Table2...etc.To get the total DB size in MB in SQL Azure, please check this command:

-- Calculates the size of the database.   
SELECT SUM(reserved_page_count)*8.0/1024  FROM sys.dm_db_partition_stats;   
GO

To get the size for each table, here is how to get the size of each table in SQL Azure:
-- Calculates the size of individual database objects.   
SELECT sys.objects.name, SUM(reserved_page_count) * 8.0 / 1024  
FROM sys.dm_db_partition_stats, sys.objects   
WHERE sys.dm_db_partition_stats.object_id = sys.objects.object_id   GROUP BY sys.objects.name; GO
So if i get the number of records in Table1 for client 1, So the storage that has been used in table1 by client 1 is equal to =Total Table Size * ( Client Records / Total Records ) 

Same will be calculated for all other tables.

The total amount of storage for client 1 is the summation Storage by client 1 for each table.
So you can show this amount in your interface under your system admin module and will be able to charge each customer on monthly basis for example.

Another question : What about the synchronization feature for cloud data in DBs ? You can either back up the database on periodic basis or do data sync in SQL Azure. Read more about SQL Azure Sync. framework:
http://archive.msdn.microsoft.com/sync/Release/ProjectReleases.aspx?ReleaseId=5037

Hope this Helps, Please post here any questions if something came across your mind ?
Thanks.

References:
- Monitoring SQL Azure Dynamic Management Views:




Regards,
Mostafa Arafa
twitter.com/mostafaelzoghbi

Thursday, February 17, 2011

C# MVP sessions schedule in Global Summit 2011

Hi All,

During MVP Global Summit 2011 that will be held from 28th Feb to 3rd March 2011, MVPs will present MVP 2 MVP side sessions during the summit days. Please check out the C# MVP side sessions schedule:

They will take place in 92/2310-Utopia (C#).

Start

Speaker

Topic

2:00 PM

Rob Vetter

Entity Framework 360: Code-Only Approach

2:20 PM

Al Pascual

Visual your data with maps.

2:40 PM

Chris Woodruff

Create an OData feed in 10 minutes

3:00 PM

D'Arcy Lussier

Using FitNesse with C#

3:20 PM

Mezil Matthieu

WF Dynamic hosting

3:40 PM

Mostafa Elzoghbi

Build cloud based solutions in Windows Azure

4:00 PM

Peter Richie

A lap around Mighty Mouse

4:20 PM

Sergey Barskiy

Testing Silverlight Applications with Silverlight Unit Test Framework

4:40 PM

Gary Short

Credit Crunch Code – Paying Back the Technical Debt

5:00 PM

Jason Bock

Evolving .NET

5:20 PM

Paul Litwin

How to speak at DevConnections


Hope this helps and see you all there.




Regards,
Mostafa Arafatwitter.com/mostafaelzoghbi

Wednesday, February 16, 2011

Unhandled exception : The file attached is not valid file error

Hi,

If you are using the Async file uploader control in AJAX Toolkit inside an update panel. when you select a file to upload, after selection, the file uploader control will be showing with Red background in the text field.

The fix for this problem is: click on the properties of the async file uploader control -> find ClientIDMode property -> change it from inherit to Auto ID.

Now try to build your web app. and select a file, The control will show the selected file with green background which means it is a valid input file validation being done by the control itself.

Enjoy !!!


Regards,Mostafa Arafa
twitter.com/mostafaelzoghbi

Thursday, January 13, 2011

Error when accessing XML Web service hosted in Windows Azure

Hi Folks,

I was developing a web role and i have a XML web service in my web role, I created a client application to access this web service. the client works on my development fabric. but after i deployed the web role in windows azure, I wasn't able to access the web service in the app fabric and i was getting this error:

{"A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond MYAPP_IP:20000"}

The problem is the App Fabric doesn't allow any inbound http connections to any role in the App Fabric unless you specify an endpoint in the service definition file.

So, the solution is to define an endpoint in the service definition file with the port specified in the web role.

To do this:

1) From VS 2010 -> Right click on the role

2) Click on Endpoints from the role properties left tab and add your End Point:

Name: HTTPInWS Protocol: Http Port: 20000

3) Build and publish your web role.

5) Add a web reference in your client application and try to consume the web service.

You will be able to access XML web service function with no errors.

Note: You have to have Azure SDK V1.3 at least to define more than endpoint in your cloud role.

Hope this helps.

Regards,
Mostafa Arafa
twitter.com/mostafaelzoghbi

Tuesday, January 04, 2011

LoggedOut Event is not firing in the Login Control

Hi Folks,
Happy New Year 2011, This is my first post in this year. Hope everyone will have happy and promising year.
In this post i'm showing an issue i faced when i was working with the login control in ASP.NET.
Problem:
If you tried to write code to clean up some resources when you log out from your asp.net application and you had an issue that the LoggedOut event handler is not firing.
Resolution:
Check the properties of your login control and if the Logout Action property is not set to Refresh, You need to update this property and set it to Refresh then your loggedout event will be handled.
I had the logout action property to redirect and that's why the loggedout event handler wasn't called in my code.

Hope this helps.
Regards,
Mostafa Arafatwitter.com/mostafaelzoghbi

Friday, December 17, 2010

FIX IT: ASP.NET 4.0 registration problem after enabling WCF activation feature in IIS 7

Hi,
If you recently enable WCF HTTP Activation Feature in IIS 7, you might face this prolem when you try to navigate to your WCF service that is targeting .Net Framework 4.0:

Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

To fix it:
1) Open VS Command Prompt.
2) Type the following command to re-install ASP.NET 4.0 and register the right .NET Framework.
aspnet_regiis.exe -iru
3) Refresh your WCF host url, it works :)

Hope this helps.
Regards,
Mostafa Arafa
twitter.com/mostafaelzoghbi

FIX IT: HTTP 404 Not Found problem when deploying WCF in IIS 7.0

Hi Folks,

I was developing a WCF syndication service to be deployed on Windows Azure, I faced a problem that when you deploy the WCF service in IIS 7.0 it doesn't work and gives the following error in the browser: HTTP 404 Not Found. I checked the deployed service it contains the dlls and configuration files. After few minutes i figured out that the problem is in one of IIS features is not enabled which is the WCF activation feature.


To fix this problem:


1) Open control panel.


2) Select programs.


3) Select Turn on/Off windows Features.


4) Look for Microsoft .Net Framework 3.5.1


5) Check WCF HTTP Activation and Non Activation check boxes (BOTH).


















6) Click ok.

7) Now your IIS is configured to host WCF services with HTTP activation and non HTTP Activation requests.
Hope this helps.
Happy New Year :)

Regards,
Mostafa Arafa
twitter.com/mostafaelzoghbi

Tuesday, November 30, 2010

Announcing New Bing maps AJAX toolkit

Hi All,

New Bing Maps AJAX control has been announced to be used on your applications. This version has been developed from the ground up to be faster and more efficient than the previous version.

Today on the Bing Maps Blog we announced the release of the new Bing™ Maps AJAX Control 7.0-our flagship for the desktop and mobile web. We built it from the ground up to be agile and fast, and it shows: at launch, the control is less than one-third the size of our previous AJAX Control 6.3 and renders multiple points nearly three times faster.*

Bing Maps Control ver. 7 :

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


Help in CHM or PDF format:

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=4a8e5de3-51af-40c3-b35d-d5e91da2effa&displaylang=en

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=9477f0fd-da1d-4822-bb67-de4cda7c7895&displaylang=en


Bing Map control is being used on your application to visualize your location based information.

Hope this helps.

Regards,Mostafa Arafa

twitter.com/mostafaelzoghbi

Thursday, October 28, 2010

Integrate External SharePoint 2010 List to Outlook 2010

Hi All,

A friend of mine asked for how to integrate SharePoint 2010 external list that is configured to pull information from an external system into outlook 2010.

So, To begin the office 2010 has unique and enhanced integration with sharepoint 2010, If you are able to configure SharePoint 2010 to pull data from external data using BCS Exteranl List. You will be able to manage this list in outlook 2010.

First, When you create external list that is designed to be used in outlook the ECT ( Exteranl Content Type ) has to be with type Office item type and select from the options: Task, Post, Appointment or contact.

How to connect to external list using SPD:
1) Open SPD with the SP site.
2) Select External content type and click on External content type from the ribbon.
3) Type the ECT name and select the office item type from the list.
4) select the data source and do the mapping.
5) Note: You have to map the fields to the appropriate office mapping.
6) Save your ECT and click on Create Lists and Form from the ribbon.
7) Now you have the ECT and the list in the SharePoint Site.
8) Before test the list, set the permission to the External list from the central admin -> application management -> application services -> select BCS -> select your list and click on set permissions - > provide the required permissions per user.
9) Visit your SP site and click on lists link and select your list to check it.

Note: I went through how to create ECT and External List in SP 2010. There is more tips and security best practices for above items - Please check MSDN how to setup BCS with SSS service.

How to get the created external list on your outlook ?
1) Select your list.
2) Select List tab and click on connect to outlook.
3) an Add-In will be installed and configured to your outlook 2010 to the list.

Now, You will be able to manage the list once the configuration is done and outlook will be launched automatically once SP 2010 is done with the configuration.












Another Question: How can i change the mapping for the created ECT ?
The only thing you need to do is to open SPD and select your ECT - > Read Item and then click on Edit Operation from the ribbon and change the ECT field mapping and save it.

Tip: if you have your outlook 2010 is opened, and you right click on the contact list and run the sync option you won't be able to get the new mapping fields. Close the outlook and open it again.













Hope this helps.

Regards,
Mostafa Arafa
twitter.com/mostafaelzoghbi

Wednesday, October 20, 2010

Avoid Run Time Errors while deploying SharePoint 2010 Solutions

Hi All,

Through my discussions with developers and attendees in SharePoint Events, I was getting a lot of questions about the target .net framework for applications and solutions that are built against Server and Client Object Model in SharePoint 2010.

I decided to list the things you need to take care and set before start compiling and deploying your solutions and getting runtime errors using SharePoint object model.

1) If you are developing a SharePoint 2010 Solutions. You solution has to target .NET Framework 3.5 Only and Not 4.0.

2) Also, if you build your solutions as layers and you have different projects ( Non SharePoint Project) all are used within your SharePoint project, ALL OF THEM HAVE TO TARGET .NET FRAMEWORK 3.5 as well.

3) Your target CPU platform can't be x86. Even if you are building a console application using the client object model. The Solution ? Next Point.

4) It's recommended that all your projects to target Any CPU platform, You can't have some projects are targeting x86 ( Such as Console Application ) that are referencing x64 CPU platform.

5) You have the option "Less Recommended" to target all your project to x64. but in this case your solution will not be able to run on x86 machines. Instead, Select Any CPU platform as recommended on Point 4.

6) If you made all your projects to target Any CPU, the only point you have to put in your consideration is the file size for your solution will be bigger than if you target x64 CPU platform.

7) If you decided to enable x64 configuration, here is the steps you need to do in VS 2010 and the resource of this post:
http://msdn.microsoft.com/en-us/library/ff407621.aspx


Hope this helps.


Regards,Mostafa Arafa
twitter.com/mostafaelzoghbi

Saturday, October 16, 2010

Sandbox Solutions in SharePoint 2010

Hi All,

Today i was presenting in SharePoint Saturday DC Federal and the event was hosted in Booz Allen Hamilton in McLean,VA.

I enjoyed the questions from Devs,Architects and attendees. It was really awesome meeting you all. The questions were primarily for secured sandbox solutions which are important for the federal employees and secured environments.


In this session i covered the following topics:
1) Sandbox overview.
2) Sandbox life cycle.
3) Developing and Deploying Sandbox solutions.
4) Custom workflow actions in workflow.
5) Custom Validator.
6) Resource Management.
7) Blocking Sandbox Solutions.
8) Points to metrics equation and how to convert points to different units.

And more...


Presentation url:
http://cid-4bc94054914a6469.office.live.com/self.aspx/SharePoint%20DC%20Federal/Sandbox%20Solutions%20In%20SharePoint%202010.pptx

Demos url:
http://cid-4bc94054914a6469.office.live.com/self.aspx/Blog%20Code/SPSDCFederal.zip

Hope this helps.


Regards,Mostafa Arafa
twitter.com/mostafaelzoghbi

Sunday, October 10, 2010

My session in Richmond Code Camp - SharePoint Development using VS 2010

Hi All,

Saturday 9th October we had a code camp in Richmond, Virginia. The Code Camp was full of new and challenging topics: Windows 7 Mobile Development, Windows Azure Development, Silverlight, WCF Data Services and JQuery and set of other topics.

My session was talking about SharePoint 2010 Development using VS 2010. In this session I covered set of great tools in VS 2010 for SharePoint Developers such as:
Feature Designer, Package Designer, SharePoint Explorer, Feature Dependency, Mapped Folders, Deployment Options and Activation steps.

The presentation has been uploaded:
http://cid-4bc94054914a6469.office.live.com/self.aspx/Richmond%20Code%20Camp/SharePoint%202010%20Development%20-%20Richmond%20Code%20Camp.pptx


Feel free to share it and use it with developers and community talks.


Regards,Mostafa Arafa
twitter.com/mostafaelzoghbi

Friday, October 01, 2010

Generate machineKey for your web.config in .NET

Hi All,

We were implemeneting Single Sign-On for our enterprise ASP.NET applications, I have been asked: How can we generate our own machine keys in our asp.net web.config ? Here is the console application you need to run and to get a random key based on the length you need and then add it to your web.config.

C# Code:

static void Main(string[] keyLength)
{

int len = 128;
if (keyLength.Length > 0)
len = int.Parse(keyLength[0]);
byte[] buff = new byte[len / 2];
RNGCryptoServiceProvider rng = new
RNGCryptoServiceProvider();
rng.GetBytes(buff);
StringBuilder sb = new StringBuilder(len);
for (int i = 0; i < buff.Length; i++)
sb.Append(string.Format("{0:X2}", buff[i]));
Console.WriteLine(sb);

}

If you didn't pass anything to this method will generate 128 character key (64 byte), If you want to get 32 byte key, you need to pass 64 as key length input.

If you are trying different cryptography algorithms provided by System.Cryptography namespace in .NET Framework so here is the reference you need to read for what is the required length for each algorithm ? either if you are using: DES,3DES,AES,SHA1...etc.

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

Hope this helps.


Regards,Mostafa Arafa
twitter.com/mostafaelzoghbi

Thursday, September 30, 2010

Why do we need managed accounts in SharePoint 2010 ?

Hi All,

SharePoint 2010 shipped with a new feature called "Managed Accounts". Managed accounts is a feature that allow sharepoint farm admins and system engineers to manage service accounts/Services created for the sharepoint 2010.

For Example: you might need a service account for your application pool or different accounts for the Sandbox solutions in SharePoint. So, You have to keep those service accounts with their password in a secured file in your system. If the password for one of those accounts has been changed, the result of this your service account will stop functioning.

The solution for this comes with SharePoint 2010 that you can register your service accounts as a Managed Accounts, and you don't need then to remember the password once you register them in your farm. and also the sharepoint 2010 will take care of the password expiry policy that you have in your organization by creating a new strong password and notify you as well. At the same time you can change the managed accounts that manage the service applications/services from the central administration.

How can i register a service account in my far ? here are the steps:
1) Open Central administration.
2) Select security.
3) Select Managed accounts.
4) Type your domain username and password you would like to register.
username: DOMAINNAME\USERNAME
password: ACCOUNTPASSWORD

5) Optional, configure SharePoint to notify you if you have password expiry policy by creating new password.

Tip: This is a good practice to enable SharePoint to generate the password for you and send a notification to you. Even if you are working in an organziation with high password requirement's policy in there, you can let SharePoint change it for you automatically to keep your environment secure and you can change it after that as well.

Once you register your managed accounts in your farm, you can then change those managed accounts to different service applications in SharePoint.

How can i change the service accounts for SharePoint services?
1) Open Central Administration.
2) Select Security.
3) Select Manage Service Accounts.
4) Select the service application and the required managed account.

Tip: Once you select the service application, you will be able to assign to any managed account in your farm.

Summary: It's recomended to create your managed accounts and use it across your farm without the need to remember the password for your accounts.

Hope this helps.


Regards,
Mostafa Arafa
twitter.com/mostafaelzoghbi

Monday, September 27, 2010

Create Reports by Business users and deploy it to SharePoint 2010

Hi All,

Usually the business users are trying to create reports for their backend DBs. You can build your own Report and deploy it to SharePoint 2010.

Without using VS.NET you can develop and create your reports using FREE Reporting tool called "Report Builder". In this tool, You can connect to your DB and build your report.

To Download SQL 2008 R2 Report Builder tool, Here is the link:
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=d3173a87-7c0d-40cc-a408-3d1a43ae4e33&displaylang=en

Once you have "SQL 2008 R2 Report Builder 3.0" tool, You can connect to your DB and you will be able to create Charts and Reports.

Once you are done, You can deploy the report by saving it locally "*.rdl" then from sharepoint Document library with Report Builder content type, You just need to upload the rdl file to the document libarary and once you click on the report you will be able to see it.

TO create the document libaray with Report builder content type, check this blog post:
http://dinesql.blogspot.com/2010/06/configuring-reporting-services-2008-r2_07.html

Once you create the document, Just upload the rdl to your Document library.

If your farm is not configured to allow SSRS reports in SharePoint 2010, read this blog:
http://moustafa-arafa.blogspot.com/2010/06/how-to-configure-reporting-services.html


Enjoy...

Regards,Mostafa Arafa
twitter.com/mostafaelzoghbi

Monday, September 20, 2010

TFS 2010 and Project Server 2010 Get Started

Hi All,

One of my colleagues asked me for useful links of TFS 2010 : Get started and training materials and Project Server 2010. Kindly find below links:

1) TFS 2010:
Homepage for all required materials for TFS 2010: Features, Training Kits, Installation and requirements management..etc:
http://msdn.microsoft.com/en-us/vstudio/ff637362.aspx

Administration and installation guide for TFS 2010:
http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&FamilyID=2d531219-2c39-4c69-88ef-f5ae6ac18c9f

Supplemental guide for TFS 2010 - CodePlex:
http://vs2010upgradeguide.codeplex.com/

2) Project Server 2010:
Get Started with Project Server 2010: Articles and Video series
http://blogs.msdn.com/b/chrisfie/archive/2010/05/26/microsoft-project-and-project-server-2010-end-user-help-documentation.aspx

Instructor-Led training and Course Training
http://www.microsoft.com/project/en/us/train-learn.aspx

Microsoft Project server: Features, Project Life cycle management + blogs
http://technet.microsoft.com/en-us/projectserver/default.aspx

Hope this helps.




Regards,Mostafa Arafa
twitter.com/mostafaelzoghbi

Thursday, September 16, 2010

SharePoint Governance Tip: Manage Self Site Creation Service and un used sites in your farm

Hi All,

I was implementing Site Creation governance practices, and i came out with the idea of this post, and I'd like to share 2 governance tips:

1) Self Site Creation Service: It is a SharePoint 2010 service that allow users to create sub sites within their site collections.

To configure Self Site Creation (SSC)Service:
Note: By Default is service is off on your web application.
1. Open SharePoint Central administration.
2. Click on Application Management Tab.
3. Under Site Collection, Click on Configure Self-Site Creation service.
4. Select your web application and select "On" from the choice option.
5. Check "Require secondary contact" to force the user to add another user to be a site administrator other than himself.

Note: When any admin clicks on OK button, A new item will be added to the announcement list of the top level site.

As a user, try to go to the top level site and click on lists and select Announcements. and you will find a new entry has been added, Try to open it, The item will have this url for users:
http://PORTALURL/_layouts/scsignup.aspx

This is the page that any site user can create a new site within the site collection.

** You can manage the SSC service using the stsadm tool:
Enable SSC serivce:
stsadm.exe -o enablessc -url -requiresecondarycontact
Disable SSC service:
stsadm -o disablessc -url


2) As a SharePoint Farm Admin if you enable this service, the next question will be:
How can i remove or take an action for un used sites? This answer is: by configure "Confirm site use and deletion":
1) Open Central Administration.
2) Select your Web Application.
3) Check the box to send email notifications after specific # of Days let's say : 60 Days
4) Specify the duration that you need backend timer serivce to check for the existing created sites: Preferred to be Daily and you can select any time as per your policy.
5) You can check to delete all site content if the site use wasn't confirmed by the site admin after specific # of notifications. (Option)

After you configure Site use confirmation and deletion you will be able to manage and monitor your site collection activities and # of sites and keep your farm operates with good performance by managing # of sites hosted on your farm.

If you are looking for a template document for site creation and maintanance sheet, check this link: http://go.microsoft.com/fwlink/?LinkId=193521

Hope this helps...

Reference:
- stsadm to manage ssc service:
http://technet.microsoft.com/en-us/library/cc261685.aspx

Regards,
Mostafa Arafa
twitter.com/mostafaelzoghbi

Tuesday, September 14, 2010

Bing Maps troubleshooting WCF services: Geocode Service

Hi All,

I was developing a WCF service that consume Bing Maps Geocode Serivce, and when i was trying to create an object from the geocodeservice, i was getting this error :

{"An endpoint configuration section for contract 'GeocodeService.IGeocodeService' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name."}

C# Code for creating a Geocode service object:

GeocodeServiceClient geocodeService = new GeocodeServiceClient();

This is beacause i have more than endpooint for my service, please check your Web.Config or the service configuration file if your WCF is not hosted within web application. You will find at least 2 endpoints are defined for your service, To fix the problem :

1) Either to remove one of the endpoints definition.
2) Keep all endpoints and select which endpoint you want to use in your code - This is the preferred solution.

C# Code for the fix : 2nd option


GeocodeServiceClient geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService");

I selected the basic HTTP binding for my service. and you can select any of your choice and you have to specify this in your code.

Hope this helps.


Regards,Mostafa Arafatwitter.com/mostafaelzoghbi

Sunday, September 05, 2010

System Services/ Service Applications in SharePoint 2010

Hi All,

In this post, I’d like to share some thoughts about SharePoint 2010 terms in regard of planning your SharePoint Farm. I will show in details the differences between some terms such as: System Services, Application Services, Cross-farm services, Single-farm services, Services associated or not to a service applications and How to configure each of them in your SharePoint Farm.
If you are familiar with SharePoint 2007, Service applications are the equivalent to Shared Services in SharePoint 2007.
1) System Services: In SP 2007, some common services were combined under Shared Services service (search, user profile…etc.), in SP 2010, each service is a standalone application, called Service Application. In SP 2010 you can configure each service application alone. Some of these system services are associated or not with a service application.
To configure System Services in SP 2010, follow these steps:
1) Open SP 2010 Central Admin
2) Select System settings
3) Click on Manage services on server
You will be able to select the servers within the farm and Start/Stop them
2) Web Application and system services: Once you create a web application in your farm, all system services are associated to your web application, You can configure which service application would you like to associate with your web application, to do so:
1) Open SP 2010 Central administration
2) Select Application Management
3) Click on Manage configure service application association
4) Click on your web application and select the required system services required
5) Select custom from the drop down list to start configure the system services associated with your web application

3) Cross-farm services vs. Single-farm services:
Cross-farm services: are the services that can be shared across different farms within the organization such as: User Profile, Managed Metadata, BCS, Search, SSS and Web Analytics.
Single-farm services: are the services that can be configured only within only one farm such as: State service, Master data services, Performance Point, Excel Services, Access Services, Word Services, Word Viewing, Power Point and Visio Service.



Regards,
Mostafa Arafa
twitter.com/mostafaelzoghbi

Wednesday, September 01, 2010

How can you deploy Windows LIVE Project Template on Azure

Hi All,

If you are developing windows live application using Window Live SDK June CTP, You won't be able to deploy your windows live application on windows azure if you didn't update your web.config by adding the following section: diagnostics.

PROBLEM: You won't be able to view any page in your web role project, and you will get a blank page.

CAUSE: Missing web.config section needs to be set on the Windows Live Project Template in VS 2010

To add this section do the following:
1) Create a new web role project in your solution.
2) Open web.config file.
3) Copy the section system.diagnostics and add it in your windows live application.
You will notice that you don't have this section on your windows live application.

4) Note: MAKE SURE THAT YOU DON'T HAVE DUPLICATE ENTRIES ON WEB.CONFIG for OAuthWrapCallback.ashx HTTP HANDLER.

5) Note: Try to update your host file by commenting the entry you have added, so when you deploy it you will be able to use the deployed url and not the host file entry that points to the localhost 127.0.0.1


Try to run the cloud service now and you will be able to view the default page of your web role.

This blog post is a result summary from my MSDN thread below:
http://social.msdn.microsoft.com/Forums/en-US/netservices/thread/cc7d0a30-a12f-4280-acbb-ed77f405acd6/

To download Windows Live SDK - June CTP for VS 2010:
http://www.microsoft.com/downloads/details.aspx?FamilyID=7fdf2281-3ee4-466a-a68f-ac71d47d6620&displaylang=en


Hope this helps.

Regards,
Mostafa Arafa
twitter.com/mostafaelzoghbi