Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to register a webpart as safe

Status
Not open for further replies.

astensland

Programmer
Sep 24, 2003
9
0
0
NO
I have created a very simple webpart. I have created a strong name for it as well. The dll file is under the bin directory, and I have also updated the web.config file with this:

<SafeControl Assembly="WebPartLibrary1, Version=1.0.0.0, Culture=neutral,PublicKeyToken=a4d8b78dc51a061f"
Namespace="WebPartLibrary1"
TypeName="*"
Safe="True"
/>

The .dwp file looks like this:

<?xml version="1.0" encoding="utf-8"?>
<WebPart xmlns=" >
<Title>WebPart1</Title>
<Description>WebPart1.</Description>
<Assembly>WebPartLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a4d8b78dc51a061f</Assembly>
<TypeName>WebPartLibrary1.WebPart1</TypeName>
<!-- Specify initial values for any additional base class or custom properties here. -->
</WebPart>

I have no problem importing the webpart, but when I try to use it I get the following error message:

"A Web Part or Web Form Control on this Web Part Page cannot be displayed or imported because it is not registered on this site as safe."

The namespace is called WebPartLibrary1.

Anybody who can help??
 
You can do this another way.

You can use the "Assembly Tool" to automatically generate your .DWP file.
Downbload from:

Any custom web part, whether you've written it or not, must be either included in the C:\Inetpub\ folder, or the Global Assembly Cache (GAC). If you choose the GAC, your web part will be implicitly trusted, as that is in part what the GAC is for. If you choose the route of using the bin folder you must then ensure that the web.config has been updated with the Safe Entry for your web part, and that the trust level is set to either 'WSS_Medium' or to 'Full' in the web.config file for your site. If this entry isn't present in the C:\Inetpub\ file your web part will error out! (Be very careful to change nothing else in the web.config file. Without this file, your SharePoint will not be usable.)

I myself take the path to the GAC.

Run the "Install Assembly tool" on the machine your running sharepoint (or WSS.

Select:
-Generate .dwps
-Pick your install location (I myself select GAC)
-Generate safe control entries

Once all these options are selected, drag and drop the .dll file into the "List of Assemblies" box.
-Click Install.

At this point the tool will write the code in the web.config file and will register the assebly in the GAC (if you choose to go that way).

If you have any questions...feel free to ask.. ;)

I apologize if Im confusing you. I dont explain as good as bart..LOL :)
 
Thanx alot TechMC.
I got it to work now. But I have a few questions. I have just installed Portal server 2003 locally on my laptop, but I am not sure if i did it correctly. When I installed it, it asked me where I wanted to to put the new portal site. It suggested (the name of my laptop. I figured that was okay. But it did not create a bin directory under intetpub\ Is it supposed to do that, or do I have to create that myself? But it did put a web.config file under inetpub\
And also, where did all the files that were created for the portal ( go? I can't find them? Where are these files created???

Regards, Anders
 
I have registered my webpart in Global Assembly,
now there is no problem displaying WP on default site , but another site on the same server with different port number still says that WP is not safe even though I had registered it globally and that port was listed during registration, also .config for both sites show the same WP as safe in <safe controls> section.
Any hints how to make WP safe on all ports ?
 
Hello 51482778,

"""where did all the files that were created for the portal ( go? I can't find them? Where are these files created???""""


Could you tell me the location of the file? I can not find the file.



Thanks,


Sean
 
I found the files. On my computer they are installed under:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\60\ISAPI....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top