I want to send an XML data to server, and to make the XML valid i have to remove all the special characters(@,#,%..) etc from the string of address and send it to server , as it accpets XML data without it, otherwise it throws error
So how can remove special characters from string using C# in ASP.NET?
Suppose my String has
...I have just started using Visual Studio code, but i am not able to format code in it, I have tried ctrl k+ Ctrl d
but it doesn't work, any helpful link for it?
I am trying to run the below code in my asp.net MVC web-application, to get the URL of first image(<img>
) in the HTML string, using the code below
public static List<Uri> FetchLinksFromSource(string htmlSource)
{
List<Uri> links = new List<Uri>();
string regexImgSrc = @"<img[^>]*?src\s*=\s*[""']?([^'"" >]+?)[ '""][^>]*?>";
MatchCollection matchesImgSrc = Regex.Matches(htmlSource, regexImgSrc, RegexOptions.IgnoreCase | RegexOptions.Singleline);
foreach (Match m in matchesImgSrc)
{
string href = m.Groups[1].Value;
links.Add(new Uri(href)); //getting error here
}
return links;
}
but I am getting this error "Invalid URI: The format of the URI could not be determined" when I run this code, here is the image of the error
...