Web.Config/Developer Dashboard/Cookie

How to read a connection string from Web.Config from your application? Using WebConfiguratonManager.

using System.Web.Configuartion;
string connectionString = WebConfigurationManager.ConnectionStrings[“MyConnectionString”].ConnectionString;


To edit Web.cong file: Use SPWebConfigModification (using feature event receiver)

Sample:

(Cannot use Sandbox solution dut to access permission issue)

Visual Studio host process is vssphost4.exe

To Turn on Enhanced Debugging Information:

[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\SharePointTools]

Change the “EnableDiagnostics” key value from “0” to “1.”
Setting this key value to 1 causes stack trace information to appear in the Output window whenever project system errors occur while you are running in Visual Studio.


Three way to change the status of developer dashboard (1) stsadm, (2) Sharepoint 2010 Management Shell and (3) Sharepoint Object Model.

(1) STSADM —
‘On’ Mode — STSADM –o setproperty –pn developer-dashboard –pv On
‘Off’ Mode — STSADM –o setproperty –pn developer-dashboard –pv Off
‘OnDemand’ Mode — STSADM –o setproperty –pn developer-dashboard –pv OnDemand


(2) Sharepoint 2010 Management Shell
$DevDashboardSettings = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.DeveloperDashboardSettings;
$DevDashboardSettings.DisplayLevel = ‘OnDemand’;
$DevDashboardSettings.RequiredPermissions = ‘EmptyMask’;
$DevDashboardSettings.TraceEnabled = $true;
$DevDashboardsettings.Update()

(3) Sharepoint Object Model
SPWebService cs = SPWebService.ContentService;
cs.DeveloperDashboardSettings.DisplayLevel = SPDeveloperDashboardLevel.OnDemand;
cs.DeveloperDashboardSettings.Update();


To Access cookies on Sharepoint:

HttpCookie cookie = new HttpCookie(cookieName);
cookie.Value = “true”;
cookie.Expires = DateTime.Now.AddDays(cookieExpires);
HttpContext.Current.Response.Cookies.Add(cookie);

Advertisements
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: