Add header on request

Add-in Express™ Support Service
That's what is more important than anything else

Add header on request
how to add headers on particular request? 
Sergey Grischenko


Add-in Express team


Posts: 7229
Joined: 2004-07-05
Hi Pavan.

You can use the getElementById method of the IHTMLDocument interface. It is accessible via the HTMLDocument property of the iemodule.
To call the msAddTrackingProtectionList function, you can use the late binding as show below:

this.HTMLDocument.parentWindow.external.GetType().InvokeMember(
"msAddTrackingProtectionList", System.Reflection.BindingFlags.InvokeMethod, null, this.HTMLDocument.parentWindow.external, new object[] { URL, description });
Posted 05 Aug, 2011 08:34:18 Top
pa1 modi




Posts: 84
Joined: 2011-06-18
hi sergey,

as you told i have use
HTMLDocument.getElementById( "http://www.fanboy.co.nz/adblock/ie/fanboy-noele.tpl" );

but it have not .value like this so how to get this??


var URL = document.getElementById("tplfile").value;
Posted 05 Aug, 2011 08:54:44 Top
Sergey Grischenko


Add-in Express team


Posts: 7229
Joined: 2004-07-05
It means that there is not any HTML element with the "http://www.fanboy.co.nz/adblock/ie/fanboy-noele.tpl" id on the page.
Try the code below:

IHTMLElement elem = this.HTMLDocument.getElementById("tplfile");
Posted 05 Aug, 2011 09:00:26 Top
pa1 modi




Posts: 84
Joined: 2011-06-18
IHTMLElement elem = this.HTMLDocument.getElementById("tplfile");

i have paste this code with no changes and apply but gives error like

System.Runtime.InteropServices.COMException (0x80020006): Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME))
Posted 05 Aug, 2011 09:31:58 Top
Sergey Grischenko


Add-in Express team


Posts: 7229
Joined: 2004-07-05
It means that the web page doesn't contain any HTML elements identified with the 'tplfile' id.
Posted 05 Aug, 2011 11:43:19 Top
pa1 modi




Posts: 84
Joined: 2011-06-18
hi sergey thanks for your quick feedback,

you mean there is no any html element identified..ok

this is also a one javascript code for check TPL is enable or not please can you provide me it in c#..??

function checkTP() {
//checks whether Tracking Protection has been enabled (any list is on)
if (window.external.msTrackingProtectionEnabled())
{
document.getElementById("results").innerHTML = "Tracking protection is: ON";
} else {
document.getElementById("results").innerHTML = "Tracking protection is: OFF";
}
}
Posted 06 Aug, 2011 00:21:37 Top
pa1 modi




Posts: 84
Joined: 2011-06-18
after run following code this error is occurs:-

Exception has been thrown by the target of an invocation. ---> System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))


code:-

string description = "Example Tracking Protection List";
string URL = "http://www.fanboy.co.nz/adblock/ie/fanboy-noele.tpl";

this.HTMLDocument.parentWindow.external.GetType().InvokeMember("msAddTrackingProtectionList", System.Reflection.BindingFlags.InvokeMethod, null, this.HTMLDocument.parentWindow.external, new object[] {url, description });

so whats the solution??
Posted 06 Aug, 2011 00:55:13 Top
pa1 modi




Posts: 84
Joined: 2011-06-18
hi,
gud morning sergey,

i have this following code for block the Ads on IE9 but its javascript code with html tags
and i wamt to use that in c# for addon so please help me to use it in c#..

code:

jav * ascript:window
<ht ml>
<head><title>Add EasyList TPL</title></head>
<body>
<a href="jav * ascript:window.external.msAddTrackingProtectionList('http://easylist-msie.adblockplus.org/easylist.tpl', 'EasyList Adblock List')">
Add EasyList TPL
</a>
</body>
</html>
Posted 08 Aug, 2011 00:36:02 Top
pa1 modi




Posts: 84
Joined: 2011-06-18
hi sergey

we wait for your reply for last post..
its urgent
Posted 08 Aug, 2011 06:33:30 Top
Sergey Grischenko


Add-in Express team


Posts: 7229
Joined: 2004-07-05
Hi Pavan.

This code doesn't work if you call it from C#. Please use the 'Tracking Protection' option in IE to enable the protection. I will let you know when I find a solution for this issue.
Posted 08 Aug, 2011 07:30:54 Top