XmlDataSource & Website Proxy

  • Thread starter Thread starter sck10
  • Start date Start date
Hello Steve,

As for the XmlDataSource control, it doesn't expose a property for us to
configure webproxy to access external web resource. Actually, the
XmlDataSource control is designed for accessing local file document or
string based Xml content mostly. For your scenario, if your XMLDataSource
want to retrieve XML Data from an external site that need to be resolved
through a proxy, you can consider the following options:

1. Since by default the XMLDatasource control will use the system proxy
setting (within the machine level .net framework system.net configuration),
we can override it in our web application's web.config file. For example:

=================================
<system.net>
<defaultProxy >
<proxy
proxyaddress="http://jpnproxy:80"
bypassonlocal="True"
/>

</defaultProxy>
</system.net>
=======================

or if you do not want to make this setting affect all pages in the
application(only for individual pages or a sub directory), you can use the
<location> element to scope the setting:

=============
<location path="XML/RSSDataSource.aspx">
<system.net>
<defaultProxy >
<proxy
proxyaddress="http://jpnproxy:80"
bypassonlocal="True"
/>

</defaultProxy>
</system.net>
</location>
=====================


2. You can also programmtically use WebRequest component(which can accept a
explicit webproxy setting) to retrieve the XML content and then assign it
to the XmlDataSource.Data property programmtically. e.g.

================
protected void Page_Load(object sender, EventArgs e)
{

//use webrequest to get the XML
string xml = GetXMLFromRemoteUrl(...);

XmlDataSource1.Data = xml;
}
================

Hope this helps. If there is any other questions, please feel free to let
me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top