Xml file: DomainList.xml
<?xml version="1.0" encoding="utf-8"?>
<DomainList>
<DomainName name="https://google.com"/>
<DomainName name="https://gmail.com"/>
<DomainName name="fonts.googleapis.com"/>
<DomainName name="fonts.gstatic.com"/>
</DomainList>
C# Code: below code check redirecting url contains in the xml file or Not
Uri sReturnUrl = new Uri(ReturnUrl);
XElement main = XElement.Load(HttpContext.Current.Server.MapPath("~/ExcelTemplates/DomainList.xml"));
var query = (from param in main.Descendants("DomainName")
where ((string)param.Attribute("name")).Contains(sReturnUrl.Host)
select new
{
code = (string)param.Attribute("name")
}).FirstOrDefault();
<?xml version="1.0" encoding="utf-8"?>
<DomainList>
<DomainName name="https://google.com"/>
<DomainName name="https://gmail.com"/>
<DomainName name="fonts.googleapis.com"/>
<DomainName name="fonts.gstatic.com"/>
</DomainList>
C# Code: below code check redirecting url contains in the xml file or Not
Uri sReturnUrl = new Uri(ReturnUrl);
XElement main = XElement.Load(HttpContext.Current.Server.MapPath("~/ExcelTemplates/DomainList.xml"));
var query = (from param in main.Descendants("DomainName")
where ((string)param.Attribute("name")).Contains(sReturnUrl.Host)
select new
{
code = (string)param.Attribute("name")
}).FirstOrDefault();
No comments:
Post a Comment