Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Webpart app.config

  Asked By: Colin    Date: Oct 24    Category: Sharepoint    Views: 5876

I have a very simple question: how to set the
app.config file for a webpart?

I have a webpart that needs a custom web service. The
URL Behavior property of the web service is set to
Dynamic to allow specific server dependent information
when the web part is deployed. By doing so, app.config
is generated which specifies the custom web service

My question is where/how do I copy my app.config. I
had the CAB project to include all project outputs but
"stsadm -o addwppack" still only copies two files:
webpart.dll and webpart.dwp.

In a standalone executable (e.g., myProgram.exe) that
uses a custom web service, I simply copy app.config to
myProgram.exe.config and put it where myProgram.exe



4 Answers Found

Answer #1    Answered By: Kalyan Pujari     Answered On: Oct 24

Two things…

First, take a look at http://www.devx.com/webdev/Article/29352 It will explain the manifest.xml file  – that’s what you need to know about to deploy more than the default dll  and dwp  file.

Second, you can’t really deploy an app.config file for a web  part. You can, however, setup a property  of your web part  that you can set  in the DWP file so users won’t see it. (You can mark the property as Browsable(false) so the users won’t see it in the user interface.)

Answer #2    Answered By: Cheryl Kelley     Answered On: Oct 24

Two other things as well, you can include  a config  file with your web  part, then use the AppSettings class and use the AppDomain to set  the APP_CONFIG_FILE property  to point to your web parts config file. Then you can read the values out of there.

You could also store the data in the registry, not as easy and safe to change as a config file, but still works.

There's also a library that someone wrote that lets you write to a dedicated config file  without changing the AppDomains config file setting.

Answer #3    Answered By: Titus Sweet     Answered On: Oct 24

It seems that all suggestions are good. I will take a
look and see which one suits my need the best.

Answer #4    Answered By: Laura Walker     Answered On: Oct 24

I typically deploy my web  Services, WSDL (as an ASPX page), and
requisite web.config files  as class resources of my Web part  assembly.

Didn't find what you were looking for? Find more on Webpart app.config Or get search suggestion and latest updates.