I have experienced to verify the URL
link in AX, Currently AX don’t contains any API that validate the URL Link
I have written a method that verifies the URL
I have written a method that verifies the URL
public static
boolean WebPathExists(str _url)
{
boolean isExists;System.Net.WebRequest UrlWebReq;
System.Net.WebResponse UrlWebRes;
try
{// Encode the URL first before passing to the Create method
_url = System.Web.HttpUtility::UrlPathEncode(_url);
UrlWebReq = System.Net.WebRequest::Create(_url);
// This is needed if secure link is access like the AX share
point portal
// This is works only for the client
callsUrlWebReq.set_Credentials(System.Net.CredentialCache::get_DefaultCredentials());
UrlWebRes = UrlWebReq.GetResponse();
// if there isn't any exception in the response (passed the above line of code) then the path is correct.
isExists = true;
}
catch
{isExists = false;
}
return isExists;
}
To checks the existence of Windows directory/File Path, there are some methods available in AX WinAPI class
WinAPI::folderExists(_filePath)
WinAPI::fileExists(_folderPath)
WinAPI::folderExists(_filePath)
WinAPI::fileExists(_folderPath)
Hi,
ReplyDeleteI did some test with this method, but I Always get that the url exists even if this not exists.
Can you please help me with this ?
thanks in advance
Iris Q.
Yes, i always get a response, regardingless if the url exists or not
ReplyDeleteAbsolutely great article to read.
ReplyDeleteI want to show my thanks to you just for rescuing me from such a circumstance. Because of looking throughout the world wide web and coming across thoughts that were not helpful, I recon this blog is the best I've ever read on this topic of Verify the URL link and the file.
ReplyDeleteHigh-quality 2017 Chiropractic Websites for Neuromuscular specialists.