Sunday, October 14, 2012

feature activation code using powershell does not pick appsettings values

This is a  very common scenario where , our deployment guides tend to be useless with automation just because features are activated well using UI in settings of site/site collection  , but fail using powershell.

Here is the solution to this :


using (SPWeb web = properties.Feature.Parent as SPWeb)
{
SPWebApplication webApp = web.Site.WebApplication;
Configuration config = WebConfigurationManager.OpenWebConfiguration("/", webApp.Name);
// App settings are retrieved this way
config.AppSettings.Settings["someAppSettingKey"].Value;


// Connection string settings are retrieved this way
config.ConnectionStrings.ConnectionStrings["someDBConnectionString"].ConnectionString
web.Site.Dispose();
}


 

Reference :

Read web.config on FeatureActivated event while activating Feature using PowerShell

 

Wednesday, October 10, 2012

Get Dependent files from HTML response

Hi

I am getting response of a page like :

System.Net.HttpWebRequest  request  ...

request.Credentials...

request.Method = ...

request.UserAgent =..

(System.Net.HttpWebResponse)request.GetResponse();

receiveStream = response.GetResponseStream();

readStream = new StreamReader(receiveStream, Encoding.UTF8);

string pageContent = readStream.ReadToEnd();

Now out of this string pageContent    , I want to extract all sub request and make them a hit.   Is there something better than html agility pack for this ?

Reply 1 By http://social.msdn.microsoft.com/profile/joel%20engineer/?ws=usercard-mini

I usually read it into an htmlDocument Class and the use either GetElementByID or GetElementsByTagname()

 

 

 

string pageContent;

webBrowser1.Document.Write(pageContent);

 




jdweng

 

Reply 2 


You should try http://htmlagilitypack.codeplex.com/

I am searching something better dear.