How to get client's computer name - asp.net

I saw this question in another post but the solution did not work correctly.
I use:
System.Net.Dns.GetHostEntry(HttpContext.Current.Request.ServerVariables.Item("REMOTE_HOST")).HostName
This worked correctly on localhost but on server it has problems and returns an empty string.
Any idea?

Two things to consider:
Take into account that HttpContext.Current.Request.ServerVariables.Item("REMOTE_HOST") will return the name of the host making the request, not the address.
Try doing System.Net.Dns.GetHostByAddress(Request.ServerVariables.Item("REMOTE_HOST")).HostName instead.
You can find a list of the Server Variables at Microsoft's MSDN website.
Hope that helps,

To get client IP address use
HttpContext.Current.Request.UserHostAddress.ToString
or
HttpContext.Current.Request.UserHostName
To get client browser use
HttpContext.Current.Request.Browser.Browser

I find out that already in VS2010 "GetHostByAddress" is deprecated.
Instead, use: System.Net.Dns.GetHostEntry(HttpContext.Current.Request.ServerVariables["REMOTE_HOST"])

Related

Domain parking in Hypernode/Ngix server

I have a domain that already setup for byte.nl hypernode server:
you can see details at:http://network-tools.com/default.asp?prog=express&host=lerenjas.nl
But I still couldn't access using lerenjas.nl and I can access by 'http://europell.hypernode.io/' what could be problem. any help would be great.
I already tried many things.
Thanks
There is nothing nginx has to do in this case. Your DNS is not set for lerenjas.nl. When you check it in the network tool url you have provided, it says "lookup failed". But for hypernode.io, lookup is successful.
So, you will have to check the byte.nl name servers.

Sequence contains no elements - DotNetOpenAuth

My sample works great on my Wifi internet at home. However, at work we have a proxy server and it is not working at all.
I enabled the default proxy and still not working. The "CreateRequest" call throws the exception:
Sequence contains no elements
Any idea? Thanks
I enabled logging and no file is being generated. What do you want me to do?
Regards
Activate logging and see what it tells you.

Not able to use windows live api on local

HI,
I have issue in using Windows live API
Iam using asp.net, am not able to use the callback url on local
The signin link is working only if i provide live url, but i cant able to use local host.
Please help
It may help someone else also -
Please add following entry in hosts file (located at [%system drive%]\Windows\System32\drivers\etc)
127.0.0.1 www.example.com
#[Please replace example domain with your actual one]
Windows live server expects your return url to have http:// in it but chrome does not add it and IE do add it, I realized this after wasting sometime.
This should get you through testing api on your local machine.
Go and setup a dynamic dns and a name for your computer and make your tests this way.
For example you can setup on DynDns.com a name for your dynamic ip, and then setup your router with that name to automatic assign it (or do it manual from the pages), and then you can use this name, and not the localhost. Do not forget to open the port to your router so the other side can make requests.
Also on /windows/system32/drivers/etc/host you can also setup the same name to see your local host and make your tests and callbacks.
Your problem is that the callback address needs to be the same as the address you used to sign up with.
(In relation to your callback), from the documentation:
The domain name portion of the URL (for example, www.contoso.com) must
be the same as the one that you specified when you created your
application with Live Connect. The URL must use URL escape codes, such
as %20 for spaces, %3A for colons, and %2F for forward slashes.
So, based on what you have said, you are using localhost (which you can't). As #Aristos suggested, add an entry to /windows/system32/drivers/etc/host to the domain you have registered (eg www.contoso.com).
Use www.contoso.com instead of localhost to test.

Replacing http responses from a specific URL in Windows

I have some software which makes a request to a specific URL in internet and I want it to receive my custom response. Is there any software tool for that on Windows? Also it would be nice if I could map a regexp instead of specific URL
Found the solution myself:
Set the domain of the URL to point to 127.0.0.1 in windows hosts file
Install nginx and set it up to show your file for the request response to which you're willing to modify and proxy all other requests to the original server
You could consider writing a test and mocking out the http response with your custom response.
I could give an example using C# and rhino mocks but it's not clear which platform you are working with.
You can:
Try to enject your dll into the process and replace functions like (HttpSendRequest, HttpQueryInfo,...) with your oun versions.
Try to use something like WinPCap (http://www.winpcap.org/).
Fiddler (www.fiddler2.com) has an AutoResponder feature which does exactly that.

How do I configure Emacs behind an authenticated HTTP proxy?

There's another question that answers this though it doesn't specify anything regarding proxy authentication.
Its solution is
(setq url-proxy-services '(("no_proxy" . "work\\.com")
("http" . "proxy.work.com:911")))
Nowadays, my approach to the "authenticated proxy problem" is to use CNTLM. It is portable, quite easy to configure and may be run as deamon.
I get authorization working without user interaction by:
(setq url-proxy-services
'(("no_proxy" . "^\\(localhost\\|10.*\\)")
("http" . "proxy.com:8080")
("https" . "proxy.com:8080")))
(setq url-http-proxy-basic-auth-storage
(list (list "proxy.com:8080"
(cons "Input your LDAP UID !"
(base64-encode-string "LOGIN:PASSWORD")))))
This work for Emacs 24.3. It based on non-public API tricks, so might not work in anther Emacs versions...
Replace LOGIN and PASSWORD with your auth info...
Well, if you really want to do this and do not mind using another program then ... socat is the answer. Use socat to forward a local port through to a connection passing through the http proxy. You are not bypassing it, just "bolting on" the functionality to an application that does not have it (in case anyone asks). This might be difficult.
Another solution that would work great if you are on a unixy OS is to install your own non-authenticating http proxy that uses the authenticating proxy (like squid). This might look like circumvention to some people. Be careful.
For example, take a look at Proxytunnel.
UPDATE: Mike Hoss seems to be correct in the comment he adds to the question linked to above. The URL package will ask for id and password. At least that is what I see in the defun for url-http-create-request in file url-http.el.
In case anyone else hits what I've just struggled with:
If you use cntlm or some other local authenticating proxy, you may need to specify a loopback IP address rather than "localhost". I found "localhost" silently failed, but "127.0.0.1" worked a treat.
ELPA uses the "url" package. As far as I know, there is no way to do proxy authentication with it.
Can you set up your proxy auth outside of Emacs?

Resources