UnsupportedUriSchemeIdentified uri max length error - c#

Hi I develop an UWP app that communicate with html page via Javascript send message app by using document.location.(document.location = "toApp://PEtPTVVU....") and i catch it with webview UnsupportedUriSchemeIdentified event .But problem is when i use a string more than 260 it gives error threw an exception of type System.UriFormatException` .Is there any solution beside a kind of link shortener
Solution for me
I used alert in html and catch encoded message like that

Related

pdfCrowd Failing on live site

I currently started using pdfCrowd for my website so users can download html as pdfs. I tested locally and it worked fine however when deploying it onto a actual website if failed with the following message:
System.Exception: Error downloading file. Please try again. --->
System.Exception: Error during rendering of Document to Pdf --->
pdfcrowd.Error: Exception of type 'pdfcrowd.Error' was thrown.
at pdfcrowd.HtmlToPdfClient.convertString(String text)...
My code in .NET looks like the following:
pdfcrowd.HtmlToPdfClient api = new pdfcrowd.HtmlToPdfClient("xxxusernamexxx", "xxxapi-keyxxx");
api.setPageMargins("3mm", "3mm","3mm", "3mm");
byte[] fileData = api.convertString(htmlString);
Not sure if I'm using the API correctly and whether I need to wait to the conversion for the html (which I insert as a string). Any incite would be helpful.

Upload of File Selenium UI Test not working for Dynamics 365 Portal

I have an issue with one of my Selenium UI tests that is running on a Dynamics 365 portal. The test is very simple:
It logs into the portal
Navigates to a certain page
Uses SendKeys to get the file from a specific location
Clicks upload button
When I run this UI test I receive a message stating "Please only upload csv files". This is correct behavior in the event that a user is attempting to upload a different file type. However, in this scenario the file extension is correct and should successfully upload. If I manually go into the portal and upload the same file myself, it uploads without error.
Has anyone experienced a similar sort of issue with a D365 portal? Or any other portal/website alike?
Below is my code to click the upload button. I have used By XPath, Id, LinkText, etc., and it all works fine.
public static void BulkUploadBrowse()
{
try
{
//Click upload button
var browse = Driver.Instance.FindElement(By.CssSelector("#AttachFile"));
browse.Click();
Thread.Sleep(1000);
}
catch (Exception ex)
{
throw (ex);
}
}
Here is the logic for uploading the file:
public static void UploadFile()
{
// Method 1 : File Upload Using Send Keys
try
{
SendKeys.SendWait(#"C:\Users\Shea.Leonard\Desktop\Upload20190625161051.csv");
Thread.Sleep(1500);
SendKeys.SendWait(#"{ENTER}");
}
catch (Exception ex)
{
throw (ex);
}
}
I have also attempted another method using the AutoITX3 Library:
//Method 2 : File Upload Using Auto IT || Leaving this here incase method 1 stops working.
AutoItX3 autoIt = new AutoItX3();
autoIt.WinActivate("Open");
autoIt.Send(#"F:\Users\adm_shea.leonard\Desktop\Upload20190625161051.csv");
Thread.Sleep(1000);
autoIt.Send("{ENTER}");
However, I still get the same error.
Based on this it should upload a file successfully. Not sure if this is an issue with Selenium WebDriver and the D365 Portal Add-on. The error message we receive, "Please only upload csv files", is specified in the Web Form configuration of the Dynamics portal.
That same file is valid because, as mentioned, I have been able to successfully upload it manually through the portal.
Any help would be much appreciated.
The first thing I would try is to leave the .csv extension off your SendKeys.SendWait(#"C:\Users\Shea.Leonard\Desktop\Upload20190625161051.csv"); line of code.
So try it just like this:
SendKeys.SendWait(#"C:\Users\Shea.Leonard\Desktop\Upload20190625161051");
This is just a sanity test to make sure the .csv file extension isn't duplicated for any reason.
Another thing I would try, is running some Javascript to make your File Upload input element visible, like this:
var fileInputElement = Driver.FindElement(By.CssSelector("#AttachFile"));
// display the file input so we can send keys
(IJavaScriptExecutor)_driver.ExecuteScript("arguments[0].style.display = 'block';", fileInputElement);
fileInputElement.SendKeys(#"C:\Users\Shea.Leonard\Desktop\Upload20190625161051.csv");
If that doesn't work, I would try manually navigating to this page and right clicking on the file input element that you are sending keys to.
Using devtools, you can manually enter text into the file input element (just as WebDriver does) and you can see if the same issue occurs there. Once you do that comparison, you will have a better idea if the issue has to do with WebDriver, or with the Webpage itself.
Lastly....I would also experiment using different file path string formats. For example, you use (#"C:\Users\Shea.Leonard\Desktop\Upload20190625161051.csv"). I would also try using ("C:\\Users\\Shea.Leonard\\Desktop\\Upload20190625161051.csv");as a sanity test to make sure there's nothing wrong with the file path you are providing.
The fact that you are receiving an error message relating to the file .csv format leads me to believe you are on the right track with this. The most likely scenario here is that manually uploading the file & automating the file upload are sending different text strings to the UI. So experimenting with different text strings that you send to the file input may resolve your issue.

Scraping htmlagilitypack

I am using HtmlAgilityPack to perform Scraping in C # Asp.Net, so far I have not had problems when doing Scratch from several web, however, trying to eject the following code I get an error
Var getHtmlWeb = new HtmlWeb ();
Var home page = getHtmlWeb.Load ("https://www.corfo.cl/sites/cpp/home");
The error that appears is:
"Connection terminated: Unexpected sending error."
The only web that is giving me problems is Corfo and not how to solve this.
I appreciate your help
This site relies on cookie to work, e.g. one of the URL it requested is
https://www.corfo.cl/sites/Satellite;jsessionid=T8w78ZolfWgr3ZoEBBvE81nBiXbXIdjfF1In3bgpZiYvL_w8TF4p!1081543155!-596930586?c=Page&cid=1456408322328&pagename=CorfoPortalPublico/Page/corfoListadoOfertaInteligenteWebLayout
So, when you request www.corfo.cl, first it forward to www.corfo.cl/sites/cpp/home, then on /sites/ folder, it set cookie jsessionid=OHS_1~T8w78ZolfWgr3ZoEBBvE81nBiXbXIdjfF1In3bgpZiYvL_w8TF4p!1081543155!-596930586 etc.
With this cookie, this page build itself with all/some components related with this jsessionid.
If client code doesn't handle these logic, as above two lines, the server reset the connection as expected, because server doesn't know how to build this page without jsessionid.
The inner exception from System.Net.WebException is
{"Authentication failed because the remote party has closed the transport stream."}
Hope this helps!

Simple Error handling in windows phone sdk

I have created a simple app which will do some calcualtions when user input some values.The app is working properly but when user forget to input some values in a textbox and run the app; the app stops working and it hangs. I want to know is there any simple error handling script for windows phone sdk.
I have used this error handiling script before in visual basic and in their its work perfectely.
On Error GoTo error_handler
Dim one,two ....
//some codes
.
.
......
error_handler:
Textblock1.Text = "Error"
I tried to use this above script in sdk but its showing this error
Requested operation is not available because the runtime library function 'Microsoft.VisualBasic.CompilerServices.ProjectData.CreateProjectError' is not defined.
As i asked in the question i was looking for a simple error handling script. I have found "accidently" the error handling script using try and catch method.Below is the code i used for error handiling.
Try
// Your code for app
Catch ex As Exception
MessageBox.Show(ex.Message.ToString(), "Error!", MessageBoxButton.OK)
End Try

How to catch 500 internal server error in c#

Im using Google Analytics Dashboard Control which are available at
http://gadashboardcontrols.codeplex.com/
Issue is its working fine when im connected to internet but if im using it on a machine that doesnt have internet access then it shows
Server Error in '/' Application.
The remote name could not be resolved: 'www.google.com'
I want to catch this exception and shows a friendly message to user. Im calling these dashboard control on my View in an iframe like this
<iframe src="../../GoogleAnalytics/Visitor.aspx" height="275"></iframe>
and if i place try catch in Visitor.aspx page it doesnot catch the exception. How should i catch this exception, Im using asp.net mvc 2 with c#
You cannot catch this exception because the problem occurs in the browser and not on the server. You do not have control over this from the aspx code.
What you can do instead is check network connectivity and serve alternate content in the page if the user is offline. Look into
System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable() for this.
There's no good way to catch this exception since you're using an iframe and the page is loaded in the browser and not via code. There are some tricks for this, but not as reliable.
The error is server-side so should actually try to fix it in your code.

Categories