How to connect localhost of windows to iphone simulator in mac - ios

I have xamarin.forms application for iOS and local database is created in sql server 2012 on windows 10,now i am trying to connect the localhost to the of windows to the iphone simulator.
i tried :
Connecting through IP address of the windows Pc.
Connected mac and windows under same wifi.
Disabled firewall.
none of them worked.
The code i am trying to connect is:
private string Uri = "http://192.168.0.16:62271/";//Windows Ip address:localhost port number
private string GetDishesUrl = "api/DishDetails/GetDishDetails?id=5";
try
{
var httpClient = new HttpClient();
httpClient.BaseAddress = new Uri(Uri);
var response = await httpClient.GetAsync(new Uri(Uri + GetDishesUrl));
var stringAsync = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode)
{
var responseJson = stringAsync;
return JsonConvert.DeserializeObject<List<DishDetails>>(responseJson);
}
}
catch(Exception ex)
{
return null;
}
when i disabled firewall and trying to connect to mac then i am getting responseas null and also the exception also as null and in safari while giving Ip address along with GetDishesUrl getting as Bad Request-Invalid Hostname,How to acheive this local host connection?
I already placed this this but i did not get it to be worked.

Related

Report Server authentication in .net core 2.1 linux container

I am migrating a .net core 2.1 app from windows server to linux container. It uses SQL Server 2008 report server.
The old app version is running on IIS (windows server), application pool with identity configured (active directory user).
The new app version is running on an alpine container using kestrel .net core server standalone, no identity configured.
When the app tries to reach SQL Server 2008 report server there is an error:
LoadReport error: One or more errors occured. (NTLM authentication is not possible with default credentials on this platform.)
How can I configure credentials (username and password)(same one set in my old application pool) in my new app based on linux container?
Part of my appsettings.json:
"Reporting": {
"ServerUrl": "http://myserver/ReportServer",
"ReportPath": "/Folder/Reports/"
},
Part of the source code:
private ServerReport PrepararRelatorio()
{
ReportSettings settings = new ReportSettings
{
ReportServer = this.configuration["Reporting:ServerUrl"]
};
ServerReport serverReport = new ServerReport(settings);
return serverReport;
}
protected FileContentResult CarregarRelatorio(
string nomeRelatorio,
string extensao,
Dictionary<string,string> parametros)
{
var renderType = this.ObterTipoRenderizacao(extensao);
if (ReportRenderType.Null.Equals(renderType))
{
throw new BusinessException("Erro ao definir o tipo do arquivo a ser exportado.");
}
ServerReport serverReport = this.PrepararRelatorio();
ReportRequest request = new ReportRequest
{
RenderType = renderType,
Path = this.configuration["Reporting:ReportPath"] + nomeRelatorio,
Name = nomeRelatorio,
ExecuteType = ReportExecuteType.Export,
Parameters = parametros
};
ReportResponse response = serverReport.Execute(request);
if (response.Status != 0)
{
throw new BusinessException(response.Message);
}
return File(response.Data.Stream, response.Data.MimeType, nomeRelatorio + "." + extensao);
}
Microsoft don't provide support for .NET Core/.NET 5, since the SSRS
library is intricately linked with WebForms, which are no longer
supported.
Refer this link
Usually, we use NetworkCredential option to pass username and password while in ASP.NET MVC.
You can able to supply report server's username and password to ReportSettings.Credential as shown in below.
Configuration:
"Reporting": {
"ServerUrl": "http://myserver/ReportServer",
"ReportPath": "/Folder/Reports/",
"UserName": "xxxxxx",
"Password": "yyyyyy"
},
Source Code:
private ServerReport PrepararRelatorio()
{
ReportSettings settings = new ReportSettings
{
ReportServer = this.configuration["Reporting:ServerUrl"],
Credential = NetworkCredential(this.configuration["Reporting:UserName"], this.configuration["Reporting:Password"])
};
ServerReport serverReport = new ServerReport(settings);
return serverReport;
}

virtual host using jerseyclient 1.18

Can anyone help me how to implement below using jerseyclient 1.18,this is most probably related to virtual host.
curl -k -H 'Host:b' https://a
Generally i just know how to connect one ip using code like below
Client client = Client.create();
WebResource webResource2 = client.resource("https://a");
ClientResponse response2 = webResource2.accept("application/json").header("user-agent", "").get(ClientResponse.class);
if (response2.getStatus() != 200) {
throw new RuntimeException("Failed : HTTP error code : " + response2.getStatus());
}
String output2 = response2.getEntity(String.class);
System.out.println("\n============Response============");
System.out.println(output2);

Mystified.. socket.io client with swift stopped connecting to node.js, socket.io server?

So I built an app that runs a socket server on port 4000. This is the main part of the server (I've removed redundant functions to the question)
var express = require('express');
var config = require('./config');
var https = require('https');
var client = require('./redis/client');
var socketio = require('./data/socket');
var app = express();
app.use(express.static(__dirname + '/static'));
app.set('port', config.PORT);
var server = app.listen(app.get('port'), function() {
console.log('Listening on port ' + server.address().port);
});
var io = socketio.listen(server);
var users = io.on('connection', function(socket) {
var user;
console.log("connected")
}
On the client I have the following (also removed redundant handlers, etc):
var socket: SocketIOClient!
init() {
socket = SocketIOClient(socketURL: "http://localhost:4000")
setupHandlers()
socket.connect()
}
func setupHandlers() {
socket.on("connect") {
data, ack in
print("connected")
self.socket.emit("addUser", self.app.data._id)
}
}
This was working. Then I created a new version of the project and exported this code and it didn't work. So I ran my older version that was working and low and behold that was also not working.
I've been spending days trying to find out why, altering code, testing, blablabla and have come out with nothing.
My only guess now is that maybe an xcode update or something else has changed some hidden file somewhere or something that is preventing connection from the app to the server...
If anyone has any idea of what could be the problem I would be forever grateful!!

Xamarin.iOS: Saving files to windows shared folder

I have an iOS app written using Xamarin. Is there a way to save some file (in my case Image) to a shared folder on Windows PC? iOS device and PC are in the same WiFi network, so I can get access to PC machine by IP address. But how can I save a file to that shared folder?
If that is possible I would be grateful for some code example.
Are you try SharpCifs.Std?
NuGet Package is here.
drives SMB on Xamarin.iOS, like this.
var file = new SmbFile("smb://UserName:Password#ServerName/ShareName/Folder/NewFileName.txt"));
file.CreateNewFile();
var writeStream = file.GetOutputStream();
writeStream.Write(Encoding.UTF8.GetBytes("Hello!"));
In my Xamarin application (on iPad Pro 12.9") I kind of worked around this problem by activating FTP on my Windows10 machine (see Google how to do this) and then uploaded the image to the Windows folder via FTP:
private void UploadImage(UIImage image, string fileName)
{
try
{
string ftpPath = "ftp://192.168.47.79/"; // IP of my Windows10 pc
string ftpTargetFilePath = $"{ftpPath}{fileName}";
var credentials = new NetworkCredential("ftpuser", "ftp");
FtpWebRequest request = (FtpWebRequest) WebRequest.Create(ftpTargetFilePath);
request.Credentials = credentials;
request.Method = WebRequestMethods.Ftp.UploadFile;
request.UsePassive = false; // in my case I needed passive mode to be deactivated
using (Stream imageStream = image.AsPNG().AsStream())
{
using (Stream ftpStream = request.GetRequestStream())
{
imageStream.CopyTo(ftpStream);
}
}
}
catch (Exception ex)
{
Debug.WriteLine($"Uploading Image: Failed! ({ex.Message})");
}
}

AuthenticateAsClient: System.IO.IOException: Received an unexpected EOF or 0 bytes from the transport stream

Due to Heartbleed, our Gateway Server was updated and this problem presented itself.
Due to POODLE, SSLv3 is no longer supported.
Note, the problem is only present on Win7+ boxes; WinXP boxes work without issue (same code, different OS = problem); granted WinXP is no longer a valid OS, just wanted to make note of functionality.
Client application (.NET 2.0) sits on a Windows 7 (or 8) box. Server runs within a DMZ behind a Gateway Server. Just to note, I found that this problem is no longer present on .NET 4.0+ - however due to legacy code, I do not have the luxury of updating.
Gateway Server is a pass through box on which Apache HTTP Server with SSL run. Its location is outside the DMZ, and it is used to access the Server which is inside the DMZ. Versions of software running on the Gateway server are Apache/2.2.25 (Win32), mod_jk/1.2.39, mod_ssl/2.2.25, OpenSSL/1.0.1g
Here is the code used on the Client application (with an exorbitant amount of logging added) ... note, 'serverName' typically contains a value such as "https://some.url.com"
private bool ConnectAndAuthenicate(string serverName, out TcpClient client, out SslStream sslStream)
{
client = null;
sslStream = null;
try
{
client = new TcpClient(serverName, 443); // Create a TCP/IP client; ctor attempts connection
Log("ConnectAndAuthenicate: Client CONNECTED"));
sslStream = new SslStream(client.GetStream(), false, ValidateServerCertificate, null);
Log("ConnectAndAuthenicate: SSL Stream CREATED"));
}
catch (Exception x)
{
Log("ConnectAndAuthenicate: EXCEPTION >> CONNECTING to server: {0}", x.ToString()));
if (x is SocketException)
{
SocketException s = x as SocketException;
Log("ConnectAndAuthenicate: EXCEPTION >> CONNECTING to server: Socket.ErrorCode: {0}", s.ErrorCode));
}
if (client != null) { client.Close(); client = null; }
if (sslStream != null) { sslStream.Close(); sslStream = null; }
}
if (sslStream == null) return false;
try
{
sslStream.ReadTimeout = 10000; // wait 10 seconds for a response ...
Log("ConnectAndAuthenicate: AuthenticateAsClient CALLED ({0})", serverName));
sslStream.AuthenticateAsClient(serverName);
Log("ConnectAndAuthenicate: AuthenticateAsClient COMPLETED SUCCESSFULLY"));
return true;
}
catch (Exception x)
{
Log("ConnectAndAuthenicate: EXCEPTION >> AuthenticateAsClient: {0}", x.ToString()));
client.Close(); client = null;
sslStream.Close(); sslStream = null;
}
return false;
}
Note - answers posted pertaining to ServicePointManager have absolutely no effect on the outcome of this application.
Every time that AuthenicateAsClient() is called when application is run on Win 7+ box, the exception occurs - if application is run on WinXP box, code works properly without exceptions.
Any ideas for solutions are very welcome.
Following the trail of setting the ServicePointManager.SecurityProtocol static ctor with a SecurityProtocolType, I found mention of another enum called SslPolicy -- further research found that AuthenicateAsClient has an overload that takes SslPolicy as an argument.
Changing this line in the above code fixed this problem:
sslStream.AuthenticateAsClient(serverName, null, SslPolicy.Tls, false);

Resources