dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


advertisement
 

Developing Web Parts for SharePoint Portal Server 2003 in .NET : Page 4

This article provides a step-by-step introduction to developing Web Parts using Visual Studio .NET by showing you how to build both simple and complex Web Part components. Along the way, you'll see how to debug Web Parts both locally and remotely—and learn a few tricks and tips.


advertisement

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Creating SafeControls
Before you can add the Web Part to the Web page, you have to make the server trust your Web Part. You do this by adding some information to the web.config file's SafeControls section. Each SafeControls entry identifies an Assembly that contains one or more trusted Web Parts. Each <SafeControl> element has four attributes, as shown in Table 1.

Table 1: The SafeControl element accepts these attributes.
SafeControl AttributeDescription
AssemblyThis is the name of the assembly that contains one or more Web Parts. For this application, the assembly name is MyWebPart1 (the same value that's in the Assembly element in the .dwp file). The Assembly attribute can also contain version, culture, and public key token information.
NamespaceThe .NET namespace for the Web Part class. For this application, use MyWebPart1 (the same namespace specified in the TypeName element in the .dwp file.
TypeNameThis is the class name of the Web Part. It's easier to use an asterisk (*) to include all Web Part classes within the specified assembly and namespace so that when you later add a new Web Part to the application, you don't have to make any more changes to the web.config file.
SafeBy default this element contains the value true. It must contain true to make your Web Part trusted. Administrators can set this value to false to make this Web Part unavailable.

After you make the changes to trust the Web Part, your web.config file will look similar to the following code:

<SafeControls> <SafeControl Assembly="System.Web, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Namespace="System.Web.UI.WebControls" TypeName="*" Safe="True" /> <SafeControl Assembly="System.Web, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Namespace="System.Web.UI.HtmlControls" TypeName="*" Safe="True" /> <SafeControl Assembly="Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" Namespace="Microsoft.SharePoint" TypeName="*" Safe="True" /> <SafeControl Assembly="Microsoft.SharePoint.Portal, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" Namespace= "Microsoft.SharePoint.Portal.WebControls" TypeName="*" /> <SafeControl Assembly="Microsoft.SharePoint.Portal, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" Namespace= "Microsoft.SharePoint.Portal.WebControls.Alerts" TypeName="*" /> <SafeControl Assembly="MyWebPart1" Namespace="MyWebPart1" TypeName="*" Safe="True" /> </SafeControls>

TIP: Make sure that you save the web.config file after adding the SafeControl entry.

If the Web Part is not declared in the SafeControl section, you'll see the error message shown in Figure 10 when you add the Web Part to the Web page.

Figure 10: If you add an untrusted Web Part to a page, you'll see this error message.




Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date