Building ASP.NET Web Parts for Windows SharePoint Services 3.0

Play Building ASP.NET Web Parts for Windows SharePoint Services 3.0

The Discussion

  • User profile image

    Very nice... 

    I have one question about adding web parts as safe to the web.config file...

    We are using Sharepoint Portal server and I don't have a web.config located in the inpub/wwwroot directory as shown in the clip.

    Where is the web.config file we need to edit for Portal Server?
    Thank you in advance.


  • User profile image
    Are you using SPS 2003 or Office SharePoint Server 2007 beta 2?
  • User profile image
    Doncho, thanks I am using Office SharePoint Server 2007 beta 2
  • User profile image


    I am still needing the answer - you or anyone at MS care to answer?  Time is of the essense...

  • User profile image

    Never mind Doncho - found it...

    In our case


    One of the virtual directories...

    Works great!

    Big Smile:D

  • User profile image

    Sorry I took so long to get back to you.  Glad you found it.


  • User profile image

    Good demo. I have some questions about making it work for me on my system. I am running WSS 3.0 Beta 2 and the bin directory and web.config file were not located at C:\inetpub\wwwroot\. I did find the virtual directories that someone else pointed out but again no folder specifically name "bin" was there. Could the litware.dll be placed under the _app_bin directory or the App_GlobalResources directory? I modified the web config file there and created a bin folder. When I go to the Web Part Gallery and select New, I do not see the litware web part to add.


    Any suggestions?

  • User profile image

    Sounds like you have done the same as I did...  Not sure why it wouldn't show up...

  • User profile image
    AH HA! I think I got it figured out. I had to name the class in the web.config file rather than use "*". Then SharePoint sees the webpart. Funny though, I can go back to the web.config file and change the Typename back to "*" and it still works.

    Big Smile
  • User profile image
    The default installation for WSS will use a GUID for the root directory.  If you create create a new web site in IIS and enable WSS on it then you can specify the physical directory to use instead of a random GUID.  This is useful for development situations where you want to have a stable path for your code to use with source control software.
  • User profile image
    Strange thing happens, or rather doesn't happen.
    When I create new library and put in the same code as in the video, the output library goes to my BIN folder and my we.config file has a safe entry I still cannot see the webpart from galery. In other words I can't find the galery to populate it and be able to use webpart.

    Any ideas?
  • User profile image


    I had problem adding a webpart to the webpart gallery too.

    I have to reboot the machine to add a webpart in the "add new webpart to a gallery" list.
    I can't get a refresh if I change the webpart in VS2K5 (and re-generate it).

    I don't have a intpub/wwwroot/web.config, so I modified the web.config or every virtualdirectory.

    I use MOSS2007beta2 (without tech refresh) and WSS3. French version upgraded form Sharepoitn server 2k3.


  • User profile image
    i did as you said, but i tried to add it, this message appeard to me "helloworld: Assemblies that implement Asp.Nety Web Parts and are installed into a partialy trusted location, such as the bin directory, must be compiled with the AllowPartiallyTrustedAttribute set for import to succeed"

    any idea plz.
  • User profile image
    Great demo, but here's my dilemma: I'd really like to leverage our existing ASP.NET user controls by writing a simple web part (as described in this demo) but that calls Page.LoadControl() to load one of our ASP.NET user controls.

    I've seen lots of examples on how to create a simple web part that outputs some simple text, but I've been stymied when it comes to finding any good examples of the LoadControl() technique.  I've actually done this from another example I found, but I keep getting this error:

    Assemblies that implement ASP.NET Web Parts and are installed into a partially trusted location, such as the bin directory, must be compiled with the AllowPartiallyTrustedCallersAttribute set for import to succeed.

    Any thoughts??


  • User profile image
    I am not able to watch the video.
    Is the link is broken or the server is too busy??
  • User profile image
    Excellent introductory tutorial on v3 web parts development, Charles!  Even though, I am watching this over a year after the fact, I have a couple of questions: are the *.webpart files stored in the SharePoint databases after SharePoint creates them?  Second, do I have to modify the web.config file and install the *.dll on ALL web servers if I have a multi-server/cluster farm deployment OR does SharePoint somehow replicate this for me?

    Thanks in advance, Charles.
    Shola Salako.
  • User profile image
    Hi, did you ever get an answer to how to apply a web part to a multiple WFE server farm?  Does one have to copy the dll to each bin directory?

    Also, I am also getting the error message:
    "...must be compiled with the AllowPartiallyTrustedCallersAttribute set to succeed"

    Did anyone find a workaround for this? I have the following line set in my assembly file:
    [assembly: System.Security.AllowPartiallyTrustedCallers()]

    And my web.config has the following line:

    <SafeControl Assembly="FooWebParts, Version=, Culture=neutral, PublicKeyToken=645f96a346d0edda" Namespace="FooWebParts" TypeName="*" Safe="True" />

    Any help would be greatly appreciated....
  • User profile image
    I ran into the same error, not sure if its the same thing... But i found that my code was throwing an exception. Tried some exception handling when i found the error it had nothing to do with the error that was reported.

    "must be compiled with the AllowPartiallyTrustedCallersAttribute set to succeed"

    Well in my code i was attempting to access a web service in the constructor and apparently no permissions are granted at this point. Changed the code to run in the CreateChildControls and like magic it worked....

    Hope this helps
  • User profile image
    I ran into the issue many others have mentioned in this thread while going through this exercise, first mentioned in skought's post.  As the video was created during the (early?) beta process some of the instructions no longer apply to the GA product. 

    Specifically I followed the instructions to have the DLL file (aka assembly) written out to c:\inetpub\wwwroot\bin.  This folder is there in my machine and the build put the file there without any trouble.  The correct location of the file on my machine is:


    Also, when it was time to edit the web.config file it was not in the folder specified in the video (c:\inetpub\wwwroot).  Instead the proper folder to find the file to edit is:


    Like some others I did a search for all instances of web.config in the c:\inetpub\wwwroot path and modified multiple instances of the file.  It wasn't until I put the actual DLL file in the correct bin folder that the web part actually showed up for me.


    While I was frustrated by the fact that my web part wasn't working when trying to follow along with an extremely elementary exercise, I have to (grudgingly) admit that I learned more about the whole process by having to repeat the steps multiple time and beat my head against the wall in frustration.
  • User profile image

    Thank you for this basic walk through.  It worked like a charm!  I would like to use SQL and AD data in the webpart and haven't found any med-advanced code snippits on how to accomplish this.  Do you have any suggestions on where to look?




    the w3b1d10t.

  • User profile image

    I too faced the same error.

    Assemblies that implement Asp.Nety Web Parts and are installed into a partialy trusted location, such as the bin directory, must be compiled with the AllowPartiallyTrustedAttribute set for import to succeed"

    But the good thing is, I was able to resolve the error.

    While creating the project VS 2005 added a signature file <filename>.snk file.

    Please delete the <*.snk> file from the project and rebuild the project. Then put the DLL in the bin directory of the web site......

    Now you should be able to add the web part to the SharePoint site.

    Hope this helps you...Smiley

  • User profile image

    I faced the same problem. Did everything everybody else previously mentioned.

    How I solved it. I created a web part project under VS2005 with WSS extensions installed. Then built the project (and this is the important bit) and deployed it using VS2005's Build>Deploy <Project> menu. VS2005 did its magic and got it working.

    BTW, deleting the Temporary.snk file did not work for me.




  • User profile image

    Doing what did (VS2005 Build->Deploy menu) worked for me as well. Din't try the other possibilities.

  • User profile image

    I am quite new to Sharepoint and ASP .NET technologies so I appologize if my question is too simple.

    This tutorial is great but I can't imagine creating all controls by writing the code manually.

    Is this possible to create eg. new ASP .NET web appliaction in Visual Studio 2008... create a Web Part using Web Parts Toolbox and other controls in "visual" mode and then populate it somehow to the sharepoint site? Just like dll's ?

    Thanks in advance for the response.

    Best regards.
  • User profile image
    thanks for the video..i am quiet new to sharepoint and so i just followed the video to create my wep parts..however when i try to deploy my web parts i got this message and  error:

    "Load of property 'OutputPath' failed. The entered path is not a valid output path"

    "System.NullReferenceException: object reference not set to an instance of an object."

    i have set my output path to the bin folder..and also i have tried the suggestions written here..but still having the same error..

    any suggestion is welcomed!
  • User profile image
    abdul waheed

    good example.thanks

Add Your 2 Cents