There are
multiple ways that you can deploy this Web Part; for example, you could add a
strong name and deploy to the GAC. Or you can deploy it to the bin directory of
the website you are using, which is the option this article uses.
1.
Right mouse the project in the solution explorer.
2.
Select properties.
3.
Select the Build tab.
4.
Change the output path to the bin directory of the site you are
deploying to. If the bin directory does not exist you can create a new one. As indicated previously, we do not need to develop this webpart on the development server. So
one example you can use as your output path is seen below. The good part of
this means you can develop simple webparts on any version of Windows using Visual Studio 2005, then deploy to your intended location:
\\<servername>\c$\Inetpub\<sharepoint-root>\bin.
5.
Now build your project using <Control><Shift><B> or
from the menu options.
6.
Now you need to build a safe entry in the Web.config. Open the Web.config
file with Visual Studio.
7.
Locate a safe control entry, such as the line with
Microsoft.Office.Excel.WebUI, and make a copy below the original line.
8.
Notice that all of Microsoft’s lines use a four part strong name. This
example does not need a four part name since we are not using strong names. You
can use just the Assembly name without the .dll extension, in this case
"HelloWorldWebPart."
9.
Next, replace the namespace, in this case "HelloWorldWebPart."
10. Finally,
fill in the type name. You can add any of the methods you have written that you
want to deem safe to expose or use "*" for all methods.
Listing 3
<SafeControl Assembly="HelloWorldWebPart"
Namespace="HelloWorldWebPart" TypeName="*" />
11. The
act of saving the Web.config file is enough to reset the application, so there
is no need to perform an iisreset. The site will automatically recycle to get
the changes.