Can't open page in browser from Visual Studio - c#

I checked out a project from TFS I had worked on a while ago, but when I pressed ctrl+F5 to launch it from Visual Studio, I got this message:
This address uses a network port which is normally used for purposes other than Web browsing. Firefox has canceled the request for your protection.
How do I open this page?

Right click on the project and select Properties. Select the "web" tab and select "Auto assign Port" under Servers. Visual studio will automatically assign a port when it runs for you.
Or if you know a port which is available to use, you can specify that in the "specific port" section.

Try the following:
Type about:config in the firefox address bar.
Search for network.security.ports.banned.override (if this doesn't exist... right click and create it - [new]->[string])
Set the port number to a number you want to use with cassini. You can also use a range of ports (eg 8080-8090)
Once you have done this, you can then set the port to be used in visual studio as Shyju has suggested but instead of setting it to auto-assign port set it to the port you have configured in step 3 above.

It is because the dynamic port of the visual studio is blocked by Firefox. See the solution here
Solution
Taken from the above link
The built in webserver in Visual Studio 2005, formerly known as Casini, uses a dynamic or static port on the localhost machine (e.g. http://localhost:2049/default.aspx).
It is dynamic by default, but you can make it static if you choose. That works very well except when you try it in Firefox. It simply gives you this response:
This address uses a network port which is normally used for purposes other than Web browsing. Firefox has cancelled the request for your protection.
It does that by default whenever you use a port other than port 80 - the default website port. It took me a lot of digging to find the solution and here it is.
- Open Firefox
Type about:config in the address field
Right click anywhere on the screen
Click new > string
Enter preference name as: network.security.ports.banned.override
Enter string value as: 2049 (or whatever port number you want)

Change the port? (right click the project and properties (or alt + enter) and Specify port

Related

Allow data traffic on Cellular device Win10 C#

I'm trying to make in C # to allow the data traffic of the Cellular device (wwan) when the user clicks disable or when the windows starts letting it as "disabled" (in case a problem) , however I can only enable / disable the device.(hardware) The problem is that when enabling the device, it will not necessarily connect if the user click "disable" the cell phone as shown in the image below.
Tried with, WMI Win32_NetworkAdapter
And also with the new class MSFT_NetAdapter
But on both I can only enable / disable the device. So if the customer accidentally clicked turned off, it doesn't automatically reconnect.
Figure 1 Has the enabled device but the cellular option is disabled
Figure 2 What I want is enable and disable the cellular option like picture above.
NOTE: I am in .net framework 4.8 because I am doing a service for Windows.
NOTE¹: I tried to use the Xamarin library which I know has the capacity for this, but without success.
Resume:
How to enable cell phone traffic if the user has disabled it?
Tag: C #, C # Console
Microsoft has made a description on how to connect a mobile connection:
https://learn.microsoft.com/en-us/windows/iot-core/connect-your-device/mbb
and also released the code on github
https://github.com/ms-iot/iot-utilities/tree/master/MBBConnect
At least they invoke netsh mbn connect interface=Mobilfunk connmode=name name=GUID to connect the interface
To check state (enabled/disabled):
netsh mbn show radio interface=Mobilfunk
to enable:
netsh mbn set powerstate interface=Mobilfunk state=on
If I got your question correct then you can try this as well, make a service to check for the bellow registry Key value and change it accordingly.
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WwanSvc\GroupPolicy
Dword:
DisableWwanAutoConnect
Set the value to 1
You can also refer this
There is a sample on how to turn on / off the Wifi and Bluetooth, but not for Cellular connection: https://github.com/microsoft/Windows-universal-samples/tree/master/Samples/RadioManager
If you loop deeper, they are not available at the current version of Windows:
https://learn.microsoft.com/en-us/uwp/api/windows.devices.radios.radiokind
MobileBroadband 2 A mobile broadband radio.
Note
This value is defined for future use and is not currently available.

Not able to publish a C# Project to an FTP Server - Visual Studio - ClickOnce

can someone please teach me how to publish a c# project to an FTP Server by using Visual Studio ClickOnce interface?
I've tried publishing to my home file server, and it is working just fine. (If there is an update, program detects and asks the user if they want to update.)
But the problem occurs when I try to publish to the ftp server.
Let me show you visually:
...
.
I've tried using a "redirecting page", url-shortener, but didn't work. (The reason why I tried them was that it accepts urls with "http://" prefix.)
I also could not find any useful information at 'msdn'.
Maybe because I did not know how to search for this (wrong keywords, etc..).
edit:
[It is uploading new versions to the FTP Server, but not reading since the URL is not working]
Additionally I do not know should I also iclude userName and Password since the directory is not accessible without them? For example:
ftp:// [userName] : [password] # [ip/domainName] / [projectDirectory] /

(W10) Register application to manage phone numbers in web browsers (like skype)

I need to register my app coded in c# on (at least) Windows10, in order to make it elegible to open URLs that are phone numbers on web browsers (preferably Chrome). If i'm not wrong, skype does/did it. Anyone knows how to do it?
Best regards and thanks in advance :)
UPDATE: Thanks to Oscar for his answer.
I've tried to put this keys:
HKEY_CLASSES_ROOT
tel
(Default) = "URL:tel Protocol"
URL Protocol = ""
DefaultIcon
(Default) = "c:\Program Files\Test\Test.exe,1"
shell
open
command
(Default) = "C:\Program Files\Test\Test.exe" "%1"
When I click a phone number with this scheme ("tel:nnnnnnnnn"), both Chrome and IE open a new windown allowing me to choose what app open, but my custom app doesn't appear :(
UPDATE 2: Seems like is not possible to do it on W10 (see comments bellow)
It involves writing some keys to register the tel: URI as handled by your application.
HKEY_CLASSES_ROOT
alert
(Default) = "URL:Alert Protocol"
URL Protocol = ""
DefaultIcon
(Default) = "alert.exe,1"
shell
open
command
(Default) = "C:\Program Files\Alert\alert.exe" "%1"
See this article for a full description:
https://msdn.microsoft.com/en-us/library/aa767914(v=vs.85).aspx
And this one about the tel: URI
https://www.rfc-editor.org/rfc/rfc3966
Seems like is not possible on W10...
The way that the applications can set itself as default ones has changed. Now the user is who decides what app should do the action... and the app has to be on the Windows Store...
See this article for a full explanation:
http://www.tenforums.com/software-apps/21303-how-do-you-set-protocol-association-standalone-exe.html

How do I remotely access self-hosted Nancy service?

I am creating a simple Windows service that hosts a Nancy instance to provide views of its internal data. Everything works as expected when using a browser on the local machine; I see the view that it serves up. However, I cannot find any reason why it will not access from a remote browser (on the same network). Access from a remote browser simply delays a while; IE will eventually display "This page can’t be displayed;" Safari on an iPad shows the partial progress bar for a while and does nothing.
I'm binding using all local IPs, not just localhost.
I am using the GetUriParams() function at this link to discover all local IP addresses for binding. http://www.codeproject.com/Articles/694907/Embed-a-web-server-in-a-windows-service
_nancyHost = new NancyHost(GetUriParams(port));
_nancyHost.Start();
I discovered at this page that binding to localhost works for local access only. http://forums.asp.net/t/1881253.aspx?More+SelfHost+Documentation
The IPs that this function discovers are for Ethernet adapter, Wireless adapter, and two VMware Network adapters from a prior installation of a VMware player. I've tried the remote access both by machine name and by literal IP to the Ethernet adapter.
I added entries to urlacl list.
I have used the netsh http add urlacl command as recommended in many places, including at this link: Remote access to a Nancy Self Host
If I perform netsh http show urlacl, I see the entry for the port I'm using.
I tried different Nancy configs
If I set the Nancy configuration option for UrlReservations.CreateAutomatically, I will get security prompts, which after allowing, I see new entries in netsh http show urlacl list output for all of the local IPs, but it still does not allow remote access. I also tried the RewriteLocalHost option true and false.
I've tried starting Nancy with http://+:3684 or http://*:3684 (which gets parsing exception from Uri()) and with http://0.0.0.0:3684 (which gets exception from AddAllPrefixes() within HttpListener()).
I added the EXE to Windows firewall
I have created firewall exceptions as described here: https://msdn.microsoft.com/en-us/library/ms733768.aspx
The associated rule shows Private,Public and "Any" for every column with both TCP and UDP.
I tried running Nancy in different environments. I've run the code in: the Windows Service running as Local System, a console app within Visual Studio 2013 debugger, and the console app Run As Administrator.
I imagine it's a simple security setting, but I've googled and searched and tried various things for a couple of days now.
What am I missing?
This answer provided the clue I needed.
https://stackoverflow.com/a/21364604/1139376
This is because HttpListener is built on top of http.sys which will listen on the port you specified on behalf of your program.
It wasn't my EXE doing the actual listening. All I needed to do was to add an Incoming rule to the Windows Firewall set for the "System" program and the specific TCP port I'm using. That allowed remote access.
Use the HostConfiguration and let Nancy make the URL reservations automaticaly for you.
var config = new HostConfiguration
{
RewriteLocalhost = true,
UrlReservations = new UrlReservations { CreateAutomatically = true }
};
host = new NancyHost(new Uri("http://localhost:8080"), new DefaultNancyBootstrapper(), config);
host.Start();
Note that this will force ACL to create network rules for new ports if they do not already exist.

Visual Web Developer (Express): Setting Document Root for Dev Environment

I'm developing a site in Visual Web Dev Express, and when I run/debug, I'd like to be able to set my application's document root so that I can use safer paths, like "/css/style.css' instead of "css/style.css". How would I accomplish this?
Click on the web site node in the solution explorer.
Press F4 to see the properties window.
Change the virtual path from /projectname to /
Bear in mind that this has an impact on how you expect the application/web site to be deployed. If it is ever used outside the root of a web server, the URL paths will be incorrect.
I have been looking for the virtual path field in the properties window but haven't been able to find it... it only shows me the following options
aperture directory URL
complete access route
policy file
port
use dynamic port
Do you know of some place else where I could find the Virtual Path field?
Select the "Web" tab and it's in the Servers section

Categories