My existing webparts won't work in SharePoint - c#

I have a standard ASP.NET 2.0 website.
It has a webpage page.
I have a webpart in my Company.Web.dll that I display on my webpart page on my website.All is good!!!
I would like to use this same webpart in SharePoint 2007.
I have a "site definition" project in VS2008 using Extensions for SharePoint 1.2. I have tried various ways to add the webpart from an outside assembly to my site definition. I have been able to deploy the webpart (where it is added to the webpart list of a webpart page) but I have been unsuccessful at adding the it to a page.
My Glorious Failures:
Created a shell webpart to just display the existing web part, basically just using my part as a control.
Attempted to modify the X.webpart and X.xml files created by VS2008 when you create a new webpart.
Both result in the following error while adding the web part to the page:
Exception
Microsoft.SharePoint.WebPartPages.WebPartPageUserException:
Cannot import XXXX Web Part.
at Microsoft.SharePoint.WebPartPages.WebPartImporter.CreateWebPart(Boolean
clearConnections) at
Microsoft.SharePoint.WebPartPages.WebPartImporter.Import(SPWebPartManager
manager, XmlReader reader, Boolean
clearConnections, Uri webPartPageUri,
SPWeb spWeb) at
Microsoft.SharePoint.WebPartPages.WebPartImporter.Import(SPWebPartManager
manager, XmlReader reader, Boolean
clearConnections, SPWeb spWeb) at
Microsoft.SharePoint.WebPartPages.WebPartQuickAdd.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument)
Is there a special way I need to add my existing webpart to my site definition?

This sounds like a problem resolving the GUID at deployment time, as you can read about in this SO question.

To find the details of why the web part won't import, check the ULS logs. These are typically located at %CommonProgramFiles%\Microsoft Shared\web server extensions\12\LOGS. An entry will be logged here at the time you attempt to add the web part to the page. This should give you more detail.
My guess is that it is a code access security issue. Your web part must be strongly signed and needs a SafeControl entry in the web.config of the SharePoint web application. Apart from these things you should be able to just add it to the Global Assembly Cache to test if it works (best practice is to write a CAS policy file). See Deploying Web Parts in Windows SharePoint Services for more details.
I would try these steps before trying to integrate it as part of a site definition. Then at least you know the web part will actually run.
Also, VSeWSS is really designed for developing your web part using it from the very start. If you have the original source, you could try creating a new web part with VSeWSS and then replace with your custom code and update the .webpart and feature XML files. Then it should behave a little better. If you haven't committed to VSeWSS, try WSPBuilder as it's less painful.

ASP.NET webparts and Sharepoint Webparts are NOT the same. You should be able to use a ASPNET webpart within Sharepoint. See the following table:
ASP.NET 2.0 Web Part
For most business needs.
To distribute your Web Part to sites that run ASP.NET 2.0 or SharePoint sites.
When you want to reuse one or more Web Parts created for ASP.NET 2.0 sites on SharePoint sites.
To use data or functionality provided by Windows SharePoint Services 3.0. For example, you are creating a a Web Part that works with site or list data.
SharePoint-based Web Part
When you want to migrate a set of Web Parts using the SharePoint-based Web Part infrastructure to Windows SharePoint Services 3.0.
To create cross page connections.
To create connections between Web Parts that are outside of a Web Part zone.
To work with client-side connections (Web Part Page Services Component).
To use a data-caching infrastructure that allows caching to the content database.
For a Sharepoint webpart to work in a standard ASPNET application you would need to recreate your webparts in Visual Studio (as an ASPNET webpart) without the Sharepoint 2007 references for it to work correctly.
One nifty tool which I have used in the past is the SmartPart Worth checking out:
This lets you create a ASP.NET usercontrol (visually) in Visual Studio and then host this in Sharepoint. The smartpart acts as a wrapper wepart for your user control. Think of it like the page viewer webpart in Sharepoint except instead of it being HTML pages its ASP.NET UserControls.

You would need WSS 3.0, SharePoint MOSS or 2007 to use ASP.NET 2.0 WebParts. SharePoint 2003 or below and WSS 2.0 or below do not support ASP.NET WebParts.

Related

Programmatically crawl Sharepoint 2013

I'm new to the SharePoint 2013 .Net Client API. I want to programmatically crawl all of a SharePoint site. I want to fully extract lists, document, pages, everything!
Ideally I want to start with the root of the website and crawl everything from there.
Can someone give a high-level overview of the basic steps involved? For example, do I need to create a catalog, or can I simply crawl if I have the admin credentials?
I'm using C#, .Net 4.0, and the Client runtime API (not REST).
Some of the links that were helpful for me :
1. Crawling with Rest API or PowerShell - Start a crawl manually via SOAP or REST WebService
2. Recrawling using code - http://sebastian.expert/force-web-whole-list-library-re-crawled-search-sharepoint-2013-using-api/
I believe that everything in SharePoint lives under a List. Essentially, I fetch the Lists belonging to a Web and fetch all the ListItems from those. I ignore Folder and File collections as these are duplicates.

convert web application to a web site

I have a c# .net VS2010 web application that contains only classic asp files.
What I want to do is convert the web application to a web site to make it easier to manage the classic asp files.
How can I convert from web application to web site? I have researched google and found lots of examples going the other way.
I don't think there's an automated way to do this. You could just create a new website in Visual Studio and copy your files from the web app into this new website. Be sure to go into each and every .aspx/.ascx file and edit the 'Codebehind' attribute so that it reads 'Codefile' (codebehind directive needs to be compiled and thus won't work in an ASP.NET website). You'll also need to delete the Designer/Designer.cs files.
Hopefully you don't have too many files so that this won't be too much of a PITA.

Sharepoint 2010 reverse proxy

I have two sites - old and new one.
The newest is Sharepoint 2010 portal. Several part of it are under construction and when user requests site which is under construction I need to return page from old portal.
I've found an article which describes how to implement Sharepoint 2010 reverse proxy using URL Revrite and Application Request Routing.
But URL to old site should contain a dinamically generated parameter.
Is this possible to interfere in Sharepoint or IIS working process to generate this parameter and change dynamically this URL address before it will be processed?
HttpModule will allow you to run some codez inside HttpRequest processor, but I'm not really sure you wanna go that route...

Adding SharePoint screen to legacy c# application

We have an Enterprise application written in C# that we well to customers. The server runs in our data center and the customers connect via a windows application also written in C#. Pretty standard.
Management would like a dashboard added to our application. I was told to look into using sharepoint to somehow add a sharepoint dashboard to the main screen of our client application (winforms).
Is this possible? The client application would have to somehow show a web page from the sharepoint server which I guess is no problem using a html componenent. But I'm more worried about getting sharepoint to work with our existing data (sql server 2008).
I suggested just writing the dashboard ourselves and avoiding sharepoint. But management would like to add more 'Business Intelligence' to our application. I know that is the way of the future but I'm worried about the complexity of integration with sharepoint.
There are various options for integrating SharePoint into a windows forms application. The simplest is embedding a web browser control and point it to the page with the dashboard set up.
Alternatively you could use the SharePoint client object model (2)(make calls to the SharePoint server) and retrieve data (and potentially pages) from SharePoint to put into your dashboard.
I would recommend to management that we can display SharePoint through our current application, and we can demonstrate with a simple dashboard part (eg chart control) to demonstrate how we can make the dashboard integrate more naturally over time piece by piece. This would minimise risk by displaying from SharePoint, while being able to show the potential advantages of using the SharePoint data and creating a customised windows forms dashboard.
SharePoint does a good job of going either way with information via BCS, assuming you would want to show LOB data in a SharePoint deployment.
However, since you want to go the other way, the Client Object Model works well with this. Seeing as how it is a .NET application, I can site specific times where we have used the built in REST services to get information from lists in our enterprise SharePoint deployments.
Security will need to be addressed as well, so don't forget about that. If you have AD groups already set up for your enterprise application, you can most likely reuse some of those in SharePoint. If you don't, you will have to now manage how data will be secured. You may also end up getting prompted for a log in to SP which is never a good user experience.
Good luck!

Where's the ASP.Net WebService in Visual Studio 2010?

I am trying to create my first webservice. I've been googling for a tutorial or examples and most of what I find is from previous versions of Visual Studio and say to create a new ASP.Net Webservice...but that doesn't exist in 2010!
What I need to do is have the service receive 2 strings, an agency and a man number. Then run a query to get some information and return a string with a date and time back to the requestor. I need to have a web interface available to call the service as well.
Any guidance on what I need to do to create the service in Visual Studio 2010 in C# will be appreciated!
Update: I've just been told that this process needs to authenticate the users...can someone guide me to information on implementing certificate or digital signatures into my web service? I've looked but most of what I'm finding is for authenticating through Active Directory or some other maintained list with usernames and passwords.
This puzzled me too. There's another puzzle to be had when you try and add a reference to an ASP.NET Web Service too, but I'll let you have fun with that one.
Change the target framework version in the dropdown list to .NET framework 2 and choose Web on the left hand side when creating a new project and it will appear.
Actually, I'm not going to be mean. If you are going to reference the web service from an application built using.NET 3.0 or higher:
Go to Add Service Reference
Go to Advanced
Click Add Web Reference at the bottom of the dialog.
In VS 2010, you can't create web services because this is covered with WCF services.
To create ASP.NET Web Services, you need to select ASP.NET app with Framework 3.5.
Visual Studio 2010 SP1, .NET Framwework 4.0
You need to create ASP.NET web site, and then Add New Item and there select from Web tab template Web Service.
Consider creating a WCF service instead. This is the evolutionary successor of the 'bare' Webservice.
When you configure the WCF server with BasicHttpBinfing you have a (SOAP) Webservice. Other binding-types (including more advanced WS-* webservices) only require changes in the config.
But for an old-style ASMX based webservice you can follow fletchers answer.
It looks like Microsoft have removed the ability to create Web Services with Visual Studio 2010 Ultimate SP1.
It does not matter what framework you are using (2, 3, 3.5, 4) the option is not available. It is unknown at this time why Microsoft made such a move. They have been hush hush over it for a while now.
THE BELOW SIMPLE STEPS WORKED THE BEST FOR ME....
create an empty website
rightclick -> add New item
and select Web Service .
This will create a empty webservice.

Categories