Thanks for reading my question.I wondered if you have any idea about this problem.
I wrote a SOAP-SERVER. Running it at CentOS. Changing Soap-Server's IPAddress for match with CentOS Ifconfig.
Running SOAP-SERVER in CentOS.
Using VisualStudio tools for AddWebReference .It'll auto generate a define object class.In this class,It containt all of function of SOAP-SERVER.
Developer will use these function for do something at ASP.Net-Client.
But,When I want to connect from ASP-NET to more SOAP-SERVER(in other CentOSs).And we musn't using AddWebReference .Because User will use web form for input IPAddress of these SOAP-SERVER.
Do you have any idea? Thanks for helping by anyway.Thanks
You'll have to keep a fixed no. of servers with same IP addresses, otherwise each time you want to access a service you'll have to change the Service proxy classes or service reference in visual studio for that matter.
What you can do is instead of letting the user enter the IP address, display a list all that you have and make him select one.
Related
I wrote an application that use grpc with ASP.NET client/server.
This application is built for watch and inform about some operations.
Because I would to have an application also compatible with linux, I transformed it in a dll, then for Windows I made a little exe that uses it, with an icon in the systray.
It works for Windows, I must test for linux except for a part, I would to get the addresses used by the server after launching... it works if I back the dll in console mode, but with the short "launcher" it's impossible (add by edit) to get the addresses with the code i wrote between balises, BUT you can connect to the server (by example i changed port in config file to verify if it was not an address by default and it works.). My problem is only to retrieve addresses after launch, i need them to add the possibility to receive a mail with addresses to connect, show them in systray..
Yesterday I found this way to get addresses used:
public void Configure(IApplicationBuilder app,...)
{
string ServerAddress = app.ServerFeatures.Get<IServerAddressesFeature().Addresses.FirstOrDefault();
// ---
}
with the short launcher the string is null while it works when I back transform the dll as a program and launch it.
I would to have an easy way, without to make big modifications when I make an app for a system or another, I have chosen what was the more compatible and would to stay in this way if possible. I know i could make an identifier to know on which system I then launch according to the OS, but i hoped to find another way in case I want to make something else with this app.
Edit:
It seems it could be a problem between the fact to launch a systray that launch Kestrel. I'm beginner with Asp .net. I copy/paste contract and constructor to the systray, it seems i have the same problem (i used a different port). I can connect but IApplicationBuilder don't have the list of adresses used.
I'm using the Neo4j desktop client for a proof of concept. I'm having trouble figuring out how to obtain credentials to call out to the Neo4j server to query from managed code. I'm using the driver, and I'm unsure how to actually obtain/manage credentials with Neo4j. All the places I've looked say that I should be able to run the following command in the terminal of the Browser for Neo4j...but doesn't work.
CALL dbms.security.createUser('username', 'password', false)
I get the following response when try to run that line.
I'm currently using version 3.3.1 for Neo4j, and it's being run as enterprise edition. Can anyone explain what is wrong? Am I missing some step to configure/unlock this API call to add a user?
It's a limitation of the Desktop version :
Anybody & everybody can get a free-for-development use (single-user,
local desktop/ single machine) license via Neo4j Desktop.
It's a single user database, so obviously you are not allow to create.
I have C# application which uses SQL Server R2 as its database. That database is on a separate PC by the name of SERVER. SQL Server's instance name also server.
My windows application uses DataSet to communicate with the database. Now my SQL installed PC name is change to another name, ex SERVERHP. Now all my coding works want to change my connection string. Are there any other easy way to do it ?
I am to tried to edit hosts file, but it does not work for me.
This is my coding style (http://goo.gl/FQrkp). I am using DataSet with DataAdapter with IDE designers.
I have 100 ~ 150 forms. Now I cannot compile all codings. I want to easy method to connect that SQL Server database.
I want to have a way to hide the change of the hostname of the computer
You have a couple of options:
Globally replace all server names with IP address in connection strings in the app
Globally replace all server names with the new server name in the app
Add a CNAME record to the DNS table on the server (assuming of course you're in the same network, which you are if you're using computer names)
Add an entry to the LMHOSTS file (you can add as many names as you'd like that point to the same IP)
As I understand, it is SqlConnection used to connect to database, or something like that. Why don't you use SqlConnectionStringBuilder? Then you can dinamically construct connection string you need. Also, to get list of servers, you can use SqlDataSourceEnumerator, from namespace System.Data.Sql.
It sounds like you want to have a way to hide the change of the hostname of the computer (Server/Desktop/Virtualized instance of Windows, whatever) that is running your SQL Server.
This isn't my area of expertise, but I can't think of a way to do it that only involves your application code and just the computer.
If you control the local DNS you can create a CNAME entry with the old name that "points" at the new one. Depending on how your connection strings are stored, you might have to edit them or you might not. But you won't have to worry about the location of your SQL Server changing again because you can always edit your CNAME to point at the new location.
Note for the future - not your current problem: If you continue to use MS SQL Server in particular you'll want to be careful about moving it to a computer where it isn't the default instance because then you need to put the instance name in the connection string as well, which might force you to edit all of your application web.configs and app.configs again.
Are you using Visual Studio 2012 with your development efforts? I ran into a conflict with the mini SQL db VS installs (Using Premium version) and had to modify the ConnectionStrings section of my Machine.config file to point to my SQL database. For whatever reason, VS will write references to the mini db in the Machine.Config file (for whatever version of .Net you are leveraging) throwing potetial conflicts.
The file can be found in %systemroot%\Microsoft.Net\Framework64\dot net version\Config
If you're using an x86 processor the Framework64 folder is just called 'Framework'.
First question!
Environment
MVC, C#, AppHarbor.
Problem
I am calling an openid provider, and generating an absolute callback url based on the domain.
On my local machine, this works fine if I hit http://localhost:12345/login
Request.Url; //gives me `http://localhost:12345/callback`
However, on AppHarbor where I'm deploying, because they are using non-standard ports, even if I'm hitting it at "http://sub.example.com/login"
Request.Url; //gives me http://sub.example.com:15232/callback
And this screws up my callback, because the port number wasn't in the original source url!
I've tried
Request.Url
Request.Url.OriginalString
Request.RawUrl
All gives me "http://sub.example.com:15232/callback".
Also to clear up that this isn't a Realm issue, the error message I am getting from DotNetOpenAuth is
'http://sub.example.com:14107/accounts/openidcallback' not under realm 'http://*.example.com/'.
I don't think I've stuffed that up?
Now, I'm about to consider some hacky stuff like
preprocessor commands (#IF DEBUG THEN PUT PORT)
string replace (Request.URL.Contains("localhost"))
All of these are not 100% solutions, but I'm sick of mulling over what could be a simple property that I am missing. I have also read this but that doesn't seem to have an accepted answer (and is more about the path rather than the authority). So I'm putting it towards you guys.
Summary
So if I had http://localhost:12345/login, I need to get http://localhost:12345/callback from the Request context.
And if I had "http://sub.example.com/login", I should get "http://sub.example.com/callback", regardless of what port it is on.
Thanks! (Sleep time, will answer any questions in the morning)
This is a common problem in load balanced setups like AppHarbor's - we've provided an example workaround.
Update: A more desirable solution for many ASP.NET applications may be to set the aspnet:UseHostHeaderForRequestUrl appSetting to true. We (AppHarbor) have seen several customers experience issues using it with their WCF apps, which is why we haven't enabled it by default and stil recommend the above solution for those situations. You can configure it using AppHarbor's "Configuration Variables" to inject the appsettings when deployed. More information can be found in this article.
I recently ran into an issue where I compared a URL to the current URL, and then highlighted navigation based on that. It worked locally, but not in production.
I had http://example.com/path/to/file.aspx as my file, but when viewing that file and running Request.Url.ToString() it produced https://example.com:81/path/to/file.aspx in a load balanced production environment.
Now I am using Request.Url.AbsolutePath to just give me /path/to/file.aspx, thus ignoring the schema, hostname, and port numbers.
When I need to compare it to the URL on each navigation item I used:
New Uri(theLink.Href).AbsolutePath
My initial thoughts are get the referrer variable and check if that includes a port, if so use it otherwise don't.
If that’s not an option because a proxy might remove the referrer header variable then you might need to use some client side script to get the location and pass it back to the server.
I'm guessing that AppHarbor use port forwarding to the IIS server so even though publicly the site is on port 80 IIS has it hosted on another port so it can't know what port the client connected on.
Something like
String port = Request.ServerVariables["SERVER_PORT"] == "80" ? "" : ":" + Request.ServerVariables["SERVER_PORT"];
String virtualRoot = Url.Content("~/");
destinationUrl = String.Format("http://{0}{1}{2}", Request.ServerVariables["SERVER_NAME"], port + virtualRoot, "/callback");
If you use the UrlBuilder class in the framework you can easly get around this. On the builder class if you set the port to -1 then the port number will be removed:
new UriBuilder("http://sub.example.com:15232/callback"){ Port = -1}
returns : http://sub.example.com/callback
To keep the port number on a local machine just check Request.IsLocal and don't apply -1 to the port.
I would wrap this into a extension method to keep it clean.
I see that this is an old thread. I had this issue running MVC5, on IIS 7.5, with an Apache proxy in front. Outside of the server, I would get "Empty Response", since the asp.net app gets the Url from apache with the custom port.
In order to have the app redirect to a subpath without including the "custom" port, forget the Response/Request objects, and use the Transfer method. For instance, if I want that users are automatically redirected to the login page in case they are not logged already:
if (!User.Identity.IsAuthenticated)
Server.TransferRequest("Account/Login");
I am working on a web application which sits on a server and connects to various client machines based on the IPAddress.I have to change the IPAddress every time in the web.config file in order to connect to a particular client machine.
I want to put a text box where i can enter the ipaddress and it updates web.config file based on the button click which should eventually connect to the respective client machine.
Is it possible to do this way or i am thinking the wrong way ?
Can any one guide me in the right path ?
It sounds to me like your thinking is backwards.
If the application is dependent on you inputting an IP address every time, why store it in the web.config? Why not just build that into the application as part of the process to connect to the machine?
Run application page, request IP input, utilize input to connect to targeted machine.
The config file is meant for rarely changing settings and other application configuration data. This is a value that is needed on a per use basis, so request it on a per use basis.
If you have a set list of IP Addresses that you're always connecting to, you can store a delimited list in the web.config and then parse it. Something like:
<add key="IPAddressList" value="192.168.1.2;192.168.10.1;192.168.15.16" />
Then, in your application, just split and loop through the list:
foreach(string ip in ConfigurationManager.AppSettings["IPAddressList"].Split(';'))
//connect to server (ip = the IP Address)
If you're dependent on input each time, then it might just be easiest to save a List of IP Addresses to the Application.Cache and update that via your page (does it need to persist?).