My Get Request Works on Browser, Fails on Mobile - c#

I have a project which front end is angular backend is .net core web api and i am using Cordova to convert this project to APK. But i have a big problem. My GET request works well on browser (which i used 'cordova run browser' command) but when i try get request on mobile, nothing happens. I am assuming that my backend works on localhost. My browser can access local host but my Android Studio Emulator phone can't access localhost. How can i fix that? Please help me thank you!
This is my code piece where i try to get request.
ngOnInit() {
document.addEventListener("deviceready", this.onDeviceReady, false);
this.onBrowserReady(); // TEST BROWSER
}
onDeviceReady() {
alert(1)
cordova.getAppVersion.getVersionCode(function(version) {
alert(2)
this.versionService.GetNewVersion().subscribe(x => {
alert(3);
this.object2 = new Object();
this.object2 = x;
});
});
}

Related

Abp backend and frontend angular - Exception not wokring

I have a abp.io backend version 7.0.0 RC and angular frontend, and my remote or backend UserFriendly exceptions are not showing in my angular application when deployed to Azure, but local they working fine.
below its how l'm showing my exceptions
throw new UserFriendlyException("exception message")
Going throught the documents this is what i have tried and still they are not showing
Configure<AbpExceptionHandlingOptions>(options =>
{
options.SendExceptionsDetailsToClients = true;
options.SendStackTraceToClients = false;
});
I have added the above to my ApplicationModule and Domain Module
it seems the issue is not related to code it might be firewall/security policy related to the enviroment you can open developer tool on browser and check the network tab to further invistigate

Don't connect to web api in emulator but work in real phone in xamarin forms

I create a xamarin cross platform project for receiving information from MVC web API,
in my android emulator project work for fine for 2 days and after 2 days when in debugging process , when debugger catch
var response = await client.GetStringAsync(url);
skip from another codes without return any data and without any error,
this is my hole codes
List<CompanyName> companyNameList = new List<CompanyName>();
string url = Constants.RestUrl + "api/Companyname";
using (HttpClient client = new HttpClient())
{
try
{
var response = await client.GetStringAsync(url);
companyNameList = JsonConvert.DeserializeObject<List<CompanyName>>(response);
}
catch (Exception ex)
{
Debug.WriteLine(#"\tERROR{0}", ex.Message);
}
}
return companyNameList;
In step one: I set SSL on my domain but problem is exist
In step two : I re-install windows and visual studio 2019 it work fine for 2 days but problem rise again,
after that with this situation I export my app and install in my real phone,
it work fine, why??
app not work on emulator but work in my phone with the same network.
Did you configure your firewall. if not please follow the below procedures.
Add an inbound firewall rule allowing access to the TCP port given in the Remote URL.
Open Windows 'Start' and type WF.msc.
Click 'Inbound Rules' on the left.
Click 'New Rules' on the right.
Choose 'Port' in the new dialog, then 'Next'.
Select TCP, and enter the port from the Remote URL next to 'Specific local ports'
(45455-45500), then 'Next'.
Next, and next (you may want to disable 'Public'), give it a name like 'MyServer: web dev server access enabled'.

Adaptive Card is not showing the image in web application

I am using the dotNet sdk. All the images are stored in the wwwroot/Image folder i.e. Static folder.
When i am running the bot through emulator i.e. Locally it is showing the image.
But after publishing the application the image is not showing up.
when i debug program remotly then i am getting the proper image path: D:\home\site\wwwroot\wwwroot\Image\pdf.jpg
, which is currect url but sill image is not showing up.
new AdaptiveColumn() {
Width=AdaptiveColumnWidth.Auto,
Items = new List<AdaptiveElement>()
{
new AdaptiveImage()
{
//Url = new Uri(iconUrl),
Size = AdaptiveImageSize.Small,
Style = AdaptiveImageStyle.Default,
UrlString=iconUrl
}
}
},
Any location starting with a drive letter like D is a local path and not a remote URL. You should never use a local path when trying to identify resources on a server, since your bot is communicating with a client on a totally different machine.
Please familiarize yourself with this document to understand how static files work in .NET Core: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files
Once your web app is running on a server, you will be able to access the image using HTTP/S. If you're running the bot locally then the URL should look something like http://localhost:3978/Image/pdf.jpg and if the bot is deployed then it should look something like https://rajatbot.azurewebsites.com/Image/pdf.jpg. Test the URL by pasting it into a browser to make sure it works, then put the URL in your card.

LoginWithApp always results in "Unable to communicate" response

I'm using the C# Facebook SDK for Windows & Windows Phone on Windows Phone 8 and trying to use the LoginWithApp approach:
public void Authenticate()
{
SessionStorage.Remove();
var client = new FacebookSessionClient(this.appId);
client.LoginWithApp("basic_info,read_stream,read_friendlist", "custom_state_string");
}
If I use the above code, it works fine in the emulator using the Login Simulator, but on a physical device I always get the following error response:
"(No connection to facebook - #2002) Connection failed: Unable to communicate with facebook in order to get the access token"
However, this can't be a simple communication problem because if I remove the read_friendlist permission it works every time.
Can anyone explain what's going on and how to fix this, please?
read_friendlist should be read_friendlists with an S on the end.

Possible bug (?) xsockets.net console server

I'm trying to start development on xsockets.net service.
My server doesn't want to recognize any of CustomController implementation for a Console Application (server). Everything works fine in Web project.
I've noticed that XSocketPlugins property contains a list of plugins. My plugin is not on a list for console App and is registered for Web.
The source code is simple like in ReadMe.txt
using (var container = XSockets.Plugin.Framework.Composable.GetExport<IXSocketServerContainer>())
{
container.StartServers();
container.OnServerClientConnection+=container_OnServerClientConnection
Console.ReadLine();<br/>
}
Defining new controller
public class CustomController1 : XSocketController
{
public void OnMessage(...)
{
//do stuff
}
}
I'm able to connect to Generic controller using C# client and JS client.
Any ideas?
Env: Windows7 64-bit, VS2012, .NET 4.0
Yes, the bug is described here: known-issues and the work around is also described.
Regarding the comment, please post the code you use to connect with the Client API and maybe I can see something in there. There should not be any problems connecting from the clients API.

Categories

Resources